diff --git a/EHEC_Server/EHEC_Server/DataBuilder/GenerateDataBuilder.cs b/EHEC_Server/EHEC_Server/DataBuilder/GenerateDataBuilder.cs index 53e8891..41f05b3 100644 --- a/EHEC_Server/EHEC_Server/DataBuilder/GenerateDataBuilder.cs +++ b/EHEC_Server/EHEC_Server/DataBuilder/GenerateDataBuilder.cs @@ -46,42 +46,42 @@ namespace EHEC_Server.DataBuilder - public static List CreatePatients() - { - //int Counter = Patients.Count(); - //for (int i = 0; i < Counter; i++) - foreach (var c in FirstNames) - { - for (int j = 0; j < 10; j++) - { - Patient patient = new Patient( - FirstNames[Rnd.Next(1, FirstNames.Count())], - LastNames[Rnd.Next(1, LastNames.Count())], - BirthDate[Rnd.Next(1, BirthDate.Count())], - Street[Rnd.Next(1, Street.Count())], - City[Rnd.Next(1, City.Count())]); - Patients.Add(patient); - } - } - return Patients; - } - - public static List CreateDoctors() - { - //int Counter = Patients.Count(); - //for (int i = 0; i < Counter; i++) - foreach (var c in FirstNames) - { - for (int j = 0; j < 10; j++) - { - Doctor doctor = new Doctor( - FirstNames[Rnd.Next(1, FirstNames.Count())], - LastNames[Rnd.Next(1, LastNames.Count())], - DoctorOrigins[Rnd.Next(1, DoctorOrigins.Count())]); - Doctors.Add(doctor); - } - } - return Doctors; - } + // public static List CreatePatients() + // { + //int Counter = Patients.Count(); + //for (int i = 0; i < Counter; i++) + // foreach (var c in FirstNames) + // { + // for (int j = 0; j < 10; j++) + // { + // Patient patient = new Patient( + // FirstNames[Rnd.Next(1, FirstNames.Count())], + // LastNames[Rnd.Next(1, LastNames.Count())], + // BirthDate[Rnd.Next(1, BirthDate.Count())], + // Street[Rnd.Next(1, Street.Count())], + // City[Rnd.Next(1, City.Count())]); + // Patients.Add(patient); + // } + // } + // return Patients; } + + // public static List CreateDoctors() + //{ + //int Counter = Patients.Count(); + //for (int i = 0; i < Counter; i++) + // foreach (var c in FirstNames) + //{ + // for (int j = 0; j < 10; j++) + //{ + // Doctor doctor = new Doctor( + // FirstNames[Rnd.Next(1, FirstNames.Count())], + // LastNames[Rnd.Next(1, LastNames.Count())], + //DoctorOrigins[Rnd.Next(1, DoctorOrigins.Count())]); + //Doctors.Add(doctor); + //} + //} + //return Doctors; + //} + } \ No newline at end of file diff --git a/EHEC_Server/EHEC_Server/DatabaseAccess/ExamAccess.cs b/EHEC_Server/EHEC_Server/DatabaseAccess/ExamAccess.cs new file mode 100644 index 0000000..c285920 --- /dev/null +++ b/EHEC_Server/EHEC_Server/DatabaseAccess/ExamAccess.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace EHEC_Server.DataBuilder +{ + public class ExamAccess + { + public bool CreateExam(Exam exam) + { + try + { + using (EHEC_DBEntities ctx = new EHEC_DBEntities()) + { + ctx.Exam.Add(exam); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + } +} \ No newline at end of file diff --git a/EHEC_Server/EHEC_Server/DatabaseAccess/OriginAccess.cs b/EHEC_Server/EHEC_Server/DatabaseAccess/OriginAccess.cs new file mode 100644 index 0000000..e8dbda9 --- /dev/null +++ b/EHEC_Server/EHEC_Server/DatabaseAccess/OriginAccess.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace EHEC_Server.DatabaseAccess +{ + public class OriginAccess + { + public bool CreateOrigin(Origin origin) + { + try + { + using (EHEC_DBEntities ctx = new EHEC_DBEntities()) + { + ctx.Origin.Add(origin); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + } +} \ No newline at end of file diff --git a/EHEC_Server/EHEC_Server/DatabaseAccess/PatientAccess.cs b/EHEC_Server/EHEC_Server/DatabaseAccess/PatientAccess.cs new file mode 100644 index 0000000..d70945e --- /dev/null +++ b/EHEC_Server/EHEC_Server/DatabaseAccess/PatientAccess.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace EHEC_Server.DatabaseAccess +{ + public class PatientAccess + { + 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 GetAllPatients() + { + using (EHEC_DBEntities ctx = new EHEC_DBEntities()) + { + return ctx.Patient.ToList(); + } + } + } +} \ No newline at end of file diff --git a/EHEC_Server/EHEC_Server/DatabaseAccess/ResultAccess.cs b/EHEC_Server/EHEC_Server/DatabaseAccess/ResultAccess.cs new file mode 100644 index 0000000..b3bf58f --- /dev/null +++ b/EHEC_Server/EHEC_Server/DatabaseAccess/ResultAccess.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace EHEC_Server.DatabaseAccess +{ + public class ResultAccess + { + public bool CreateResult(Result result) + { + try + { + using (EHEC_DBEntities ctx = new EHEC_DBEntities()) + { + ctx.Result.Add(result); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + } +} \ No newline at end of file diff --git a/EHEC_Server/EHEC_Server/Doctor.cs b/EHEC_Server/EHEC_Server/Doctor.cs index 801119b..81ad256 100644 --- a/EHEC_Server/EHEC_Server/Doctor.cs +++ b/EHEC_Server/EHEC_Server/Doctor.cs @@ -9,50 +9,24 @@ namespace EHEC_Server { - using EHEC_Server.DataBuilder; using System; using System.Collections.Generic; - using System.Linq; - using EHEC_Server.DatabaseAccess; - - public partial class Doctor : DoctorAccess + + public partial class Doctor { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public Doctor() { this.Exam = new HashSet(); } - - - public void CreateDoctors(Doctor doctor) - { - using (EHEC_DBEntities ctx = new EHEC_DBEntities()) - { - var doctors = GenerateDataBuilder.CreateDoctors(); - - foreach (var d in doctors) - { - ctx.Doctor.Add(d); - } - } - } - - - public Doctor(string firstname, string lastname, string doctororigin) - { - this.FirstName = firstname; - this.LastName = lastname; - this.DoctorOrigin = doctororigin; - } + public int DoctorId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string DoctorOrigin { get; set; } + public string Region { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection Exam { get; set; } - - - } } diff --git a/EHEC_Server/EHEC_Server/EHEC_Server.csproj b/EHEC_Server/EHEC_Server/EHEC_Server.csproj index bc401a1..7edb1e3 100644 --- a/EHEC_Server/EHEC_Server/EHEC_Server.csproj +++ b/EHEC_Server/EHEC_Server/EHEC_Server.csproj @@ -107,7 +107,11 @@ + + + + Model.tt @@ -134,6 +138,9 @@ Model.tt + + Model.tt + Model.tt @@ -144,6 +151,9 @@ Service.svc + + Model.tt + diff --git a/EHEC_Server/EHEC_Server/Exam.cs b/EHEC_Server/EHEC_Server/Exam.cs index 72d0c3d..0f8032b 100644 --- a/EHEC_Server/EHEC_Server/Exam.cs +++ b/EHEC_Server/EHEC_Server/Exam.cs @@ -14,34 +14,22 @@ namespace EHEC_Server public partial class Exam { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Exam() + { + this.Origin_Exam = new HashSet(); + } + public int ExamId { get; set; } public int DoctorId { get; set; } public int PatientId { get; set; } - public bool SicknessStatus { get; set; } - public string SicknessDesignation { get; set; } public int OriginOriginId { get; set; } public int Result_ResultId { get; set; } public virtual Doctor Doctor { get; set; } - public virtual Origin Origin { get; set; } public virtual Patient Patient { get; set; } public virtual Result Result { get; set; } - - public bool CreateExam(Exam exam) - { - try - { - using (EHEC_DBEntities ctx = new EHEC_DBEntities()) - { - ctx.Exam.Add(exam); - ctx.SaveChanges(); - } - return true; - } - catch (Exception) - { - return false; - } - } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Origin_Exam { get; set; } } } diff --git a/EHEC_Server/EHEC_Server/IService.cs b/EHEC_Server/EHEC_Server/IService.cs index dee7f35..dc9bb33 100644 --- a/EHEC_Server/EHEC_Server/IService.cs +++ b/EHEC_Server/EHEC_Server/IService.cs @@ -11,8 +11,6 @@ namespace EHEC_Server [ServiceContract] public interface IService { - [OperationContract] - void CreateRandomData(Doctor doctor); [OperationContract] void WriteDoctor(Doctor doctor); diff --git a/EHEC_Server/EHEC_Server/Model.Context.cs b/EHEC_Server/EHEC_Server/Model.Context.cs index 30635cb..305e805 100644 --- a/EHEC_Server/EHEC_Server/Model.Context.cs +++ b/EHEC_Server/EHEC_Server/Model.Context.cs @@ -30,5 +30,7 @@ namespace EHEC_Server public virtual DbSet Origin { get; set; } public virtual DbSet Patient { get; set; } public virtual DbSet Result { get; set; } + public virtual DbSet Origin_Exam { get; set; } + public virtual DbSet sysdiagrams { get; set; } } } diff --git a/EHEC_Server/EHEC_Server/Model.edmx b/EHEC_Server/EHEC_Server/Model.edmx index 235c975..6128d11 100644 --- a/EHEC_Server/EHEC_Server/Model.edmx +++ b/EHEC_Server/EHEC_Server/Model.edmx @@ -4,7 +4,7 @@ - + @@ -13,6 +13,7 @@ + @@ -21,8 +22,6 @@ - - @@ -31,11 +30,19 @@ - + + + + + + + + + @@ -46,6 +53,7 @@ + @@ -53,7 +61,16 @@ - + + + + + + + + + + @@ -67,14 +84,26 @@ - + + + + + + + + + + + + + - + - + @@ -107,15 +136,21 @@ + + - - + + + + + + @@ -126,8 +161,7 @@ - - + @@ -140,6 +174,7 @@ + @@ -148,25 +183,23 @@ - - - + - - + + @@ -175,10 +208,11 @@ - + + @@ -186,7 +220,6 @@ - @@ -201,18 +234,6 @@ - - - - - - - - - - - - @@ -247,10 +268,6 @@ - - - - @@ -259,7 +276,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -269,6 +340,7 @@ + @@ -282,8 +354,6 @@ - - @@ -292,8 +362,8 @@ + - @@ -303,6 +373,7 @@ + @@ -317,7 +388,26 @@ - + + + + + + + + + + + + + + + + + + + + diff --git a/EHEC_Server/EHEC_Server/Model.edmx.diagram b/EHEC_Server/EHEC_Server/Model.edmx.diagram index 1d57997..f258853 100644 --- a/EHEC_Server/EHEC_Server/Model.edmx.diagram +++ b/EHEC_Server/EHEC_Server/Model.edmx.diagram @@ -7,13 +7,16 @@ - + - + + + + diff --git a/EHEC_Server/EHEC_Server/Origin.cs b/EHEC_Server/EHEC_Server/Origin.cs index baee1db..d6a766f 100644 --- a/EHEC_Server/EHEC_Server/Origin.cs +++ b/EHEC_Server/EHEC_Server/Origin.cs @@ -17,33 +17,16 @@ namespace EHEC_Server [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public Origin() { - this.Exam = new HashSet(); + this.Origin_Exam = new HashSet(); } public int OriginId { get; set; } - public int SicknessId { get; set; } public string Name { get; set; } public string Street { get; set; } public string City { get; set; } + public string Food { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection Exam { get; set; } - - public bool CreateOrigin(Origin origin) - { - try - { - using (EHEC_DBEntities ctx = new EHEC_DBEntities()) - { - ctx.Origin.Add(origin); - ctx.SaveChanges(); - } - return true; - } - catch (Exception) - { - return false; - } - } + public virtual ICollection Origin_Exam { get; set; } } } diff --git a/EHEC_Server/EHEC_Server/Origin_Exam.cs b/EHEC_Server/EHEC_Server/Origin_Exam.cs new file mode 100644 index 0000000..2704dde --- /dev/null +++ b/EHEC_Server/EHEC_Server/Origin_Exam.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace EHEC_Server +{ + using System; + using System.Collections.Generic; + + public partial class Origin_Exam + { + public int Origin_ExamId { get; set; } + public int OriginOriginId { get; set; } + public int ExamExamId { get; set; } + + public virtual Exam Exam { get; set; } + public virtual Origin Origin { get; set; } + } +} diff --git a/EHEC_Server/EHEC_Server/Patient.cs b/EHEC_Server/EHEC_Server/Patient.cs index 5cdbfff..053832f 100644 --- a/EHEC_Server/EHEC_Server/Patient.cs +++ b/EHEC_Server/EHEC_Server/Patient.cs @@ -9,11 +9,12 @@ namespace EHEC_Server { + using EHEC_Server.DatabaseAccess; using System; using System.Collections.Generic; using System.Linq; - public partial class Patient + public partial class Patient : PatientAccess { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public Patient() @@ -21,7 +22,7 @@ namespace EHEC_Server this.Exam = new HashSet(); } - public Patient(string firstname, string lastname, string birthDate, string street, string city) + public Patient(string firstname, string lastname, DateTime birthDate, string street, string city) { this.FirstName = firstname; this.LastName = lastname; @@ -33,8 +34,7 @@ namespace EHEC_Server 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 DateTime BirthDate { get; set; } public string Street { get; set; } public string City { get; set; } @@ -42,29 +42,6 @@ namespace EHEC_Server public virtual ICollection 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 GetAllPatients() - { - using (EHEC_DBEntities ctx = new EHEC_DBEntities()) - { - return ctx.Patient.ToList(); - } - } } } diff --git a/EHEC_Server/EHEC_Server/Result.cs b/EHEC_Server/EHEC_Server/Result.cs index 2b9954c..5e21883 100644 --- a/EHEC_Server/EHEC_Server/Result.cs +++ b/EHEC_Server/EHEC_Server/Result.cs @@ -22,26 +22,8 @@ namespace EHEC_Server public int ResultId { get; set; } public string Name { get; set; } - public string Description { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection Exam { get; set; } - - public bool CreateResult(Result result) - { - try - { - using (EHEC_DBEntities ctx = new EHEC_DBEntities()) - { - ctx.Result.Add(result); - ctx.SaveChanges(); - } - return true; - } - catch (Exception) - { - return false; - } - } } } diff --git a/EHEC_Server/EHEC_Server/Service.svc.cs b/EHEC_Server/EHEC_Server/Service.svc.cs index 1929758..883d76c 100644 --- a/EHEC_Server/EHEC_Server/Service.svc.cs +++ b/EHEC_Server/EHEC_Server/Service.svc.cs @@ -13,11 +13,7 @@ namespace EHEC_Server // NOTE: In order to launch WCF Test Client for testing this service, please select Service.svc or Service.svc.cs at the Solution Explorer and start debugging. public class Service : IService { - public void CreateRandomData(Doctor doctor) - { - Doctor dataaccess = new Doctor(); - dataaccess.CreateDoctors(doctor); - } + public List GetDoctors() { Doctor dataaccess = new Doctor(); diff --git a/EHEC_Server/EHEC_Server/sysdiagrams.cs b/EHEC_Server/EHEC_Server/sysdiagrams.cs new file mode 100644 index 0000000..bfd7243 --- /dev/null +++ b/EHEC_Server/EHEC_Server/sysdiagrams.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace EHEC_Server +{ + using System; + using System.Collections.Generic; + + public partial class sysdiagrams + { + public string name { get; set; } + public int principal_id { get; set; } + public int diagram_id { get; set; } + public Nullable version { get; set; } + public byte[] definition { get; set; } + } +}