change the Patient class to Person in the service
Since all persons can be patients it doesn't make sense to have a seperate Patient class.
This commit is contained in:
parent
1c5bf7b9e9
commit
c27452c07e
|
@ -9,7 +9,6 @@ namespace Server.DB
|
|||
public Context() : base("EhecDB") { }
|
||||
public DbSet<Doctor> Doctors { get; set; }
|
||||
public DbSet<Person> Persons { get; set; }
|
||||
public DbSet<Patient> Patients { get; set; }
|
||||
public DbSet<Exam> Exams { get; set; }
|
||||
public DbSet<City> Cities { get; set; }
|
||||
public DbSet<Country> Countries { get; set; }
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Models;
|
||||
|
||||
namespace Server.DB
|
||||
{
|
||||
public class PatientDB
|
||||
{
|
||||
public ICollection<Patient> GetAllPatients()
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Configuration.ProxyCreationEnabled = false;
|
||||
return ctx.Patients
|
||||
.Include("Gender")
|
||||
.Include("City")
|
||||
.Include("Salutation")
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public bool CreatePatient(Patient doctor)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Patients.Add(doctor);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdatePatient(Patient doctor)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Patients.Attach(doctor);
|
||||
ctx.Entry(doctor).State = System.Data.Entity.EntityState.Modified;
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public bool DeletePatient(Patient doctor)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Patients.Attach(doctor);
|
||||
ctx.Patients.Remove(doctor);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,6 +39,6 @@ namespace Server
|
|||
[OperationContract]
|
||||
ICollection<PatientAtFoodPlace> GetRelations();
|
||||
[OperationContract]
|
||||
ICollection<Patient> GetPatients();
|
||||
ICollection<Person> GetPersons();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
using System.Runtime.Serialization;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Server.Models
|
||||
{
|
||||
[Table("Patients")]
|
||||
[DataContract]
|
||||
public class Patient : Person
|
||||
{
|
||||
public Patient() { }
|
||||
public Patient(string firstName, string lastName, Gender gender, Salutation salutation,
|
||||
string streetName, string streetNumber, City city)
|
||||
{
|
||||
this.FirstName = firstName;
|
||||
this.LastName = lastName;
|
||||
this.Gender = gender;
|
||||
this.Salutation = salutation;
|
||||
this.StreetName = streetName;
|
||||
this.StreetNumber = streetNumber;
|
||||
this.City = city;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ using System.Runtime.Serialization;
|
|||
namespace Server.Models
|
||||
{
|
||||
[DataContract]
|
||||
[KnownType(typeof(Doctor))]
|
||||
public class Person
|
||||
{
|
||||
private int _PersonID;
|
||||
|
|
|
@ -101,7 +101,6 @@
|
|||
<Compile Include="DB\ExamDB.cs" />
|
||||
<Compile Include="DB\GenderDB.cs" />
|
||||
<Compile Include="DB\PatientAtFoodPlaceDB.cs" />
|
||||
<Compile Include="DB\PatientDB.cs" />
|
||||
<Compile Include="DB\PersonDB.cs" />
|
||||
<Compile Include="DB\SalutationDB.cs" />
|
||||
<Compile Include="Helper\EntitiesContextInitializer.cs" />
|
||||
|
@ -128,7 +127,6 @@
|
|||
<Compile Include="Models\FoodPlace.cs" />
|
||||
<Compile Include="Models\Gender.cs" />
|
||||
<Compile Include="Models\Node.cs" />
|
||||
<Compile Include="Models\Patient.cs" />
|
||||
<Compile Include="Models\PatientAtFoodPlace.cs" />
|
||||
<Compile Include="Models\Person.cs" />
|
||||
<Compile Include="Models\Salutation.cs" />
|
||||
|
|
|
@ -92,10 +92,10 @@ namespace Server
|
|||
dataaccess.CreateStrain(strain);
|
||||
}
|
||||
|
||||
public ICollection<Patient> GetPatients()
|
||||
public ICollection<Person> GetPersons()
|
||||
{
|
||||
PatientDB dataaccess = new PatientDB();
|
||||
return dataaccess.GetAllPatients();
|
||||
PersonDB dataaccess = new PersonDB();
|
||||
return dataaccess.GetAllPersons();
|
||||
}
|
||||
|
||||
public void WriteRelation(PatientAtFoodPlace relation)
|
||||
|
|
Loading…
Reference in New Issue