oop_II-6/EHEC_Server/EHEC_Server/Patient.cs

71 lines
2.2 KiB
C#

//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace EHEC_Server
{
using System;
using System.Collections.Generic;
using System.Linq;
public partial class Patient
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Patient()
{
this.Exam = new HashSet<Exam>();
}
public Patient(string firstname, string lastname, string birthDate, string street, string city)
{
this.FirstName = firstname;
this.LastName = lastname;
this.BirthDate = birthDate;
this.Street = street;
this.City = city;
}
public int PatientId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
//public System.DateTime BirthDate { get; set; }
public string BirthDate { get; set; }
public string Street { get; set; }
public string City { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Exam> Exam { get; set; }
public bool CreatePatient(Patient patient)
{
try
{
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
{
ctx.Patient.Add(patient);
ctx.SaveChanges();
}
return true;
}
catch (Exception)
{
return false;
}
}
public List<Patient> GetAllPatients()
{
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
{
return ctx.Patient.ToList();
}
}
}
}