remove the "Status" model

It doesn't mather which status a doctor has for the application.
This commit is contained in:
Andreas Zweili 2018-06-04 15:59:42 +02:00
parent c90a13e01d
commit 1a780a4e35
7 changed files with 2 additions and 126 deletions

View File

@ -19,6 +19,5 @@ namespace Server.DB
public DbSet<Salutation> Salutations{ get; set; }
public DbSet<Strain> Strains { get; set; }
public DbSet<Gender> Genders { get; set; }
public DbSet<Status> Status { get; set; }
}
}

View File

@ -1,71 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Server.Models;
namespace Server.DB
{
public class StatusDB
{
public List<Status> GetAllStatus()
{
using (Context ctx = new Context())
{
return ctx.Status.ToList();
}
}
public bool CreateStatus(Status status)
{
try
{
using (Context ctx = new Context())
{
ctx.Status.Add(status);
ctx.SaveChanges();
}
return true;
}
catch (Exception)
{
return false;
}
}
public bool UpdateStatus(Status status)
{
try
{
using (Context ctx = new Context())
{
ctx.Status.Attach(status);
ctx.Entry(status).State = System.Data.Entity.EntityState.Modified;
ctx.SaveChanges();
}
return true;
}
catch (Exception)
{
return false;
}
}
public bool DeleteStatus(Status status)
{
try
{
using (Context ctx = new Context())
{
ctx.Status.Attach(status);
ctx.Status.Remove(status);
ctx.SaveChanges();
}
return true;
}
catch (Exception)
{
return false;
}
}
}
}

View File

@ -15,7 +15,6 @@ namespace Server.Helper
var salutations = GenerateData.CreateSalutations();
var genders = GenerateData.CreateGenders();
var countries = GenerateData.CreateCountries();
var statuses = GenerateData.CreateStatuses();
var cities = GenerateData.CreateCities();
var doctors = GenerateData.CreateDoctors();
@ -31,10 +30,6 @@ namespace Server.Helper
{
context.Countries.Add(c);
}
foreach (var s in statuses)
{
context.Status.Add(s);
}
foreach (var c in cities)
{
context.Cities.Add(c);

View File

@ -13,7 +13,6 @@ namespace Server.Helper
private static List<Doctor> Doctors = new List<Doctor>();
private static List<Country> Countries = new List<Country>();
private static List<City> Cities = new List<City>();
private static List<Status> Statuses = new List<Status>();
private static Random Rnd = new Random();
private static List<string> SalutationList = new List<string>(new string[]
@ -45,10 +44,6 @@ namespace Server.Helper
"Müller", "Meier", "Muster", "Bucher", "Schmidt", "Fink", "Steuri",
"Meister", "Schär", "Eberhard", "Zingg", "Howald", "Aebi", "Feldmann"
});
private static List<string> StatusList = new List<string>(new string[]
{
"Regionalarzt", "Kantonsarzt"
});
public static List<Salutation> CreateSalutations()
{
foreach (var s in SalutationList)
@ -85,14 +80,6 @@ namespace Server.Helper
}
return Cities;
}
public static List<Status> CreateStatuses()
{
foreach (var s in StatusList)
{
Statuses.Add(new Status(s));
}
return Statuses;
}
public static List<Doctor> CreateDoctors()
{
int Counter = Cities.Count();
@ -101,14 +88,13 @@ namespace Server.Helper
for (int j = 0; j < 3; j++)
{
City PersonCity = Cities[i];
Status DoctorStatus = Statuses[0];
String Streetname = "Musterstrasse " + Rnd.Next(1, 20).ToString();
Doctor doctor = new Doctor(
FirstNames[Rnd.Next(1, FirstNames.Count())],
LastNames[Rnd.Next(1, LastNames.Count())],
Genders[0],
Salutations[0], Streetname, PersonCity, DoctorStatus);
Salutations[0], Streetname, PersonCity);
Doctors.Add(doctor);
}
}

View File

@ -11,16 +11,13 @@ namespace Server.Models
public class Doctor : Person
{
private int _DoctorID;
private Status _Status;
[DataMember]
public int DoctorID { get => _DoctorID; set => _DoctorID = value; }
[DataMember]
public virtual Status Status { get => _Status; set => _Status = value; }
public Doctor() { }
public Doctor(string firstName, string lastName, Gender gender, Salutation salutation,
string streetName, City city, Status status)
string streetName, City city)
{
this.FirstName = firstName;
this.LastName = lastName;
@ -28,7 +25,6 @@ namespace Server.Models
this.Salutation = salutation;
this.StreetName = streetName;
this.City = city;
this.Status = status;
}
}
}

View File

@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace Server.Models
{
[DataContract]
public class Status
{
private int _StatusID;
private string _Name;
[DataMember]
public int StatusID { get => _StatusID; set => _StatusID = value; }
[DataMember]
public string Name { get => _Name; set => _Name = value; }
public Status() { }
public Status (string name)
{
this.Name = name;
}
}
}

View File

@ -100,7 +100,6 @@
<Compile Include="DB\ResultDB.cs" />
<Compile Include="DB\SalutationDB.cs" />
<Compile Include="Helper\EntitiesContextInitializer.cs" />
<Compile Include="DB\StatusDB.cs" />
<Compile Include="DB\StrainDB.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
@ -122,7 +121,6 @@
<Compile Include="Models\Person.cs" />
<Compile Include="Models\Result.cs" />
<Compile Include="Models\Salutation.cs" />
<Compile Include="Models\Status.cs" />
<Compile Include="Models\Strain.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Service.svc.cs">