From e8cf6f279d5a221da06ead8a60e5665071557864 Mon Sep 17 00:00:00 2001 From: ismail Date: Wed, 30 May 2018 21:44:37 +0200 Subject: [PATCH] Created the Model an DB Files for the Migration --- .../ServerWebApplication/DBModel.cs | 31 ---- .../ServerWebApplication/Global.asax | 1 - .../ServerWebApplication/Global.asax.cs | 16 -- .../ServerWebApplication/IServerService.cs | 17 -- .../ServerWebApplication/IService.cs | 17 -- .../ServerWebApplication/ServerService.svc | 1 - .../ServerWebApplication/ServerService.svc.cs | 18 --- .../ServerWebApplication.csproj | 146 ------------------ .../ServerWebApplication/Service.svc | 1 - .../ServerWebApplication/Service.svc.cs | 18 --- .../ServerWebApplication/Service1.svc | 1 - .../ServerWebApplication/Service1.svc.cs | 18 --- .../ServerWebApplication/Web.Debug.config | 30 ---- .../ServerWebApplication/Web.Release.config | 31 ---- .../ServerWebApplication/Web.config | 46 ------ .../ServerWebApplication/packages.config | 6 - .../Service_Server.sln | 8 +- Service_Server/Service_Server/App.config | 69 +++++++++ .../Service_Server/DB/Database_Model.cs | 27 ++++ Service_Server/Service_Server/DB/Doctor_DB.cs | 73 +++++++++ Service_Server/Service_Server/DB/Origin_DB.cs | 72 +++++++++ .../Service_Server/DB/PStatus_DB.cs | 72 +++++++++ Service_Server/Service_Server/DB/Person_DB.cs | 72 +++++++++ .../Service_Server}/IService1.cs | 16 +- .../Service_Server/Models/Doctor.cs | 28 ++++ Service_Server/Service_Server/Models/Exam.cs | 39 +++++ .../Service_Server/Models/Origin.cs | 12 ++ .../Service_Server/Models/PStatus.cs | 27 ++++ .../Service_Server/Models/Person.cs | 35 +++++ .../Service_Server/Models/Result.cs | 35 +++++ .../Properties/AssemblyInfo.cs | 9 +- Service_Server/Service_Server/Service1.cs | 31 ++++ .../Service_Server/Service_Server.csproj | 100 ++++++++++++ Service_Server/Service_Server/packages.config | 4 + 34 files changed, 721 insertions(+), 406 deletions(-) delete mode 100644 ServerWebApplication/ServerWebApplication/DBModel.cs delete mode 100644 ServerWebApplication/ServerWebApplication/Global.asax delete mode 100644 ServerWebApplication/ServerWebApplication/Global.asax.cs delete mode 100644 ServerWebApplication/ServerWebApplication/IServerService.cs delete mode 100644 ServerWebApplication/ServerWebApplication/IService.cs delete mode 100644 ServerWebApplication/ServerWebApplication/ServerService.svc delete mode 100644 ServerWebApplication/ServerWebApplication/ServerService.svc.cs delete mode 100644 ServerWebApplication/ServerWebApplication/ServerWebApplication.csproj delete mode 100644 ServerWebApplication/ServerWebApplication/Service.svc delete mode 100644 ServerWebApplication/ServerWebApplication/Service.svc.cs delete mode 100644 ServerWebApplication/ServerWebApplication/Service1.svc delete mode 100644 ServerWebApplication/ServerWebApplication/Service1.svc.cs delete mode 100644 ServerWebApplication/ServerWebApplication/Web.Debug.config delete mode 100644 ServerWebApplication/ServerWebApplication/Web.Release.config delete mode 100644 ServerWebApplication/ServerWebApplication/Web.config delete mode 100644 ServerWebApplication/ServerWebApplication/packages.config rename ServerWebApplication/ServerWebApplication.sln => Service_Server/Service_Server.sln (62%) create mode 100644 Service_Server/Service_Server/App.config create mode 100644 Service_Server/Service_Server/DB/Database_Model.cs create mode 100644 Service_Server/Service_Server/DB/Doctor_DB.cs create mode 100644 Service_Server/Service_Server/DB/Origin_DB.cs create mode 100644 Service_Server/Service_Server/DB/PStatus_DB.cs create mode 100644 Service_Server/Service_Server/DB/Person_DB.cs rename {ServerWebApplication/ServerWebApplication => Service_Server/Service_Server}/IService1.cs (51%) create mode 100644 Service_Server/Service_Server/Models/Doctor.cs create mode 100644 Service_Server/Service_Server/Models/Exam.cs create mode 100644 Service_Server/Service_Server/Models/Origin.cs create mode 100644 Service_Server/Service_Server/Models/PStatus.cs create mode 100644 Service_Server/Service_Server/Models/Person.cs create mode 100644 Service_Server/Service_Server/Models/Result.cs rename {ServerWebApplication/ServerWebApplication => Service_Server/Service_Server}/Properties/AssemblyInfo.cs (80%) create mode 100644 Service_Server/Service_Server/Service1.cs create mode 100644 Service_Server/Service_Server/Service_Server.csproj create mode 100644 Service_Server/Service_Server/packages.config diff --git a/ServerWebApplication/ServerWebApplication/DBModel.cs b/ServerWebApplication/ServerWebApplication/DBModel.cs deleted file mode 100644 index 60c76e2..0000000 --- a/ServerWebApplication/ServerWebApplication/DBModel.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace ServerWebApplication -{ - using System; - using System.Data.Entity; - using System.Linq; - - public class DBModel : DbContext - { - // Your context has been configured to use a 'DBModel' connection string from your application's - // configuration file (App.config or Web.config). By default, this connection string targets the - // 'ServerWebApplication.DBModel' database on your LocalDb instance. - // - // If you wish to target a different database and/or database provider, modify the 'DBModel' - // connection string in the application configuration file. - public DBModel() - : base("name=DBModel") - { - } - - // Add a DbSet for each entity type that you want to include in your model. For more information - // on configuring and using a Code First model, see http://go.microsoft.com/fwlink/?LinkId=390109. - - // public virtual DbSet MyEntities { get; set; } - } - - //public class MyEntity - //{ - // public int Id { get; set; } - // public string Name { get; set; } - //} -} \ No newline at end of file diff --git a/ServerWebApplication/ServerWebApplication/Global.asax b/ServerWebApplication/ServerWebApplication/Global.asax deleted file mode 100644 index 865ef0e..0000000 --- a/ServerWebApplication/ServerWebApplication/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="ServerWebApplication.Global" Language="C#" %> diff --git a/ServerWebApplication/ServerWebApplication/Global.asax.cs b/ServerWebApplication/ServerWebApplication/Global.asax.cs deleted file mode 100644 index 5b61692..0000000 --- a/ServerWebApplication/ServerWebApplication/Global.asax.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Security; -using System.Web.SessionState; - -namespace ServerWebApplication -{ - public class Global : System.Web.HttpApplication - { - protected void Application_Start(object sender, EventArgs e) - { - } - } -} \ No newline at end of file diff --git a/ServerWebApplication/ServerWebApplication/IServerService.cs b/ServerWebApplication/ServerWebApplication/IServerService.cs deleted file mode 100644 index 99337aa..0000000 --- a/ServerWebApplication/ServerWebApplication/IServerService.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.ServiceModel; -using System.Text; - -namespace ServerWebApplication -{ - // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IServerService" in both code and config file together. - [ServiceContract] - public interface IServerService - { - [OperationContract] - void DoWork(); - } -} diff --git a/ServerWebApplication/ServerWebApplication/IService.cs b/ServerWebApplication/ServerWebApplication/IService.cs deleted file mode 100644 index aced32c..0000000 --- a/ServerWebApplication/ServerWebApplication/IService.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.ServiceModel; -using System.Text; - -namespace ServerWebApplication -{ - // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService" in both code and config file together. - [ServiceContract] - public interface IService - { - [OperationContract] - void DoWork(); - } -} diff --git a/ServerWebApplication/ServerWebApplication/ServerService.svc b/ServerWebApplication/ServerWebApplication/ServerService.svc deleted file mode 100644 index 647ee90..0000000 --- a/ServerWebApplication/ServerWebApplication/ServerService.svc +++ /dev/null @@ -1 +0,0 @@ -<%@ ServiceHost Language="C#" Debug="true" Service="ServerWebApplication.ServerService" CodeBehind="ServerService.svc.cs" %> diff --git a/ServerWebApplication/ServerWebApplication/ServerService.svc.cs b/ServerWebApplication/ServerWebApplication/ServerService.svc.cs deleted file mode 100644 index b9d3e05..0000000 --- a/ServerWebApplication/ServerWebApplication/ServerService.svc.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.ServiceModel; -using System.Text; - -namespace ServerWebApplication -{ - // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ServerService" in code, svc and config file together. - // NOTE: In order to launch WCF Test Client for testing this service, please select ServerService.svc or ServerService.svc.cs at the Solution Explorer and start debugging. - public class ServerService : IServerService - { - public void DoWork() - { - } - } -} diff --git a/ServerWebApplication/ServerWebApplication/ServerWebApplication.csproj b/ServerWebApplication/ServerWebApplication/ServerWebApplication.csproj deleted file mode 100644 index 10b4cd0..0000000 --- a/ServerWebApplication/ServerWebApplication/ServerWebApplication.csproj +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - Debug - AnyCPU - - - 2.0 - {78D3B3D9-5CEC-42D5-B3D1-C480E688FDE1} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - ServerWebApplication - ServerWebApplication - v4.6.1 - true - - - - - - - - - True - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - true - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - - - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll - - - ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll - - - - - - - - - - - - - - - - - - - - - - - - - - Web.config - - - Web.config - - - - - - - - - - - Global.asax - - - - - ServerService.svc - - - - - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - - True - True - 58304 - / - http://localhost:58304/ - False - False - - - False - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/ServerWebApplication/ServerWebApplication/Service.svc b/ServerWebApplication/ServerWebApplication/Service.svc deleted file mode 100644 index 2616583..0000000 --- a/ServerWebApplication/ServerWebApplication/Service.svc +++ /dev/null @@ -1 +0,0 @@ -<%@ ServiceHost Language="C#" Debug="true" Service="ServerWebApplication.Service" CodeBehind="Service.svc.cs" %> diff --git a/ServerWebApplication/ServerWebApplication/Service.svc.cs b/ServerWebApplication/ServerWebApplication/Service.svc.cs deleted file mode 100644 index f68afc8..0000000 --- a/ServerWebApplication/ServerWebApplication/Service.svc.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.ServiceModel; -using System.Text; - -namespace ServerWebApplication -{ - // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service" in code, svc and config file together. - // 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 DoWork() - { - } - } -} diff --git a/ServerWebApplication/ServerWebApplication/Service1.svc b/ServerWebApplication/ServerWebApplication/Service1.svc deleted file mode 100644 index 0e83615..0000000 --- a/ServerWebApplication/ServerWebApplication/Service1.svc +++ /dev/null @@ -1 +0,0 @@ -<%@ ServiceHost Language="C#" Debug="true" Service="ServerWebApplication.Service1" CodeBehind="Service1.svc.cs" %> diff --git a/ServerWebApplication/ServerWebApplication/Service1.svc.cs b/ServerWebApplication/ServerWebApplication/Service1.svc.cs deleted file mode 100644 index 5dabd29..0000000 --- a/ServerWebApplication/ServerWebApplication/Service1.svc.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.ServiceModel; -using System.Text; - -namespace ServerWebApplication -{ - // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together. - // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging. - public class Service1 : IService1 - { - public void DoWork() - { - } - } -} diff --git a/ServerWebApplication/ServerWebApplication/Web.Debug.config b/ServerWebApplication/ServerWebApplication/Web.Debug.config deleted file mode 100644 index fae9cfe..0000000 --- a/ServerWebApplication/ServerWebApplication/Web.Debug.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/ServerWebApplication/ServerWebApplication/Web.Release.config b/ServerWebApplication/ServerWebApplication/Web.Release.config deleted file mode 100644 index da6e960..0000000 --- a/ServerWebApplication/ServerWebApplication/Web.Release.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/ServerWebApplication/ServerWebApplication/Web.config b/ServerWebApplication/ServerWebApplication/Web.config deleted file mode 100644 index 33bcffd..0000000 --- a/ServerWebApplication/ServerWebApplication/Web.config +++ /dev/null @@ -1,46 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ServerWebApplication/ServerWebApplication/packages.config b/ServerWebApplication/ServerWebApplication/packages.config deleted file mode 100644 index 243fd05..0000000 --- a/ServerWebApplication/ServerWebApplication/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ServerWebApplication/ServerWebApplication.sln b/Service_Server/Service_Server.sln similarity index 62% rename from ServerWebApplication/ServerWebApplication.sln rename to Service_Server/Service_Server.sln index 7235cbd..454584c 100644 --- a/ServerWebApplication/ServerWebApplication.sln +++ b/Service_Server/Service_Server.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27428.2027 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerWebApplication", "ServerWebApplication\ServerWebApplication.csproj", "{78D3B3D9-5CEC-42D5-B3D1-C480E688FDE1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service_Server", "Service_Server\Service_Server.csproj", "{99603770-AD97-41C1-8868-744BCEEE2926}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerWebApplication", "..\ServerWebApplication\ServerWebApplication\ServerWebApplication.csproj", "{78D3B3D9-5CEC-42D5-B3D1-C480E688FDE1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,6 +13,10 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {99603770-AD97-41C1-8868-744BCEEE2926}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99603770-AD97-41C1-8868-744BCEEE2926}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99603770-AD97-41C1-8868-744BCEEE2926}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99603770-AD97-41C1-8868-744BCEEE2926}.Release|Any CPU.Build.0 = Release|Any CPU {78D3B3D9-5CEC-42D5-B3D1-C480E688FDE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {78D3B3D9-5CEC-42D5-B3D1-C480E688FDE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {78D3B3D9-5CEC-42D5-B3D1-C480E688FDE1}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Service_Server/Service_Server/App.config b/Service_Server/Service_Server/App.config new file mode 100644 index 0000000..0ce123a --- /dev/null +++ b/Service_Server/Service_Server/App.config @@ -0,0 +1,69 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Service_Server/Service_Server/DB/Database_Model.cs b/Service_Server/Service_Server/DB/Database_Model.cs new file mode 100644 index 0000000..7ab2b2d --- /dev/null +++ b/Service_Server/Service_Server/DB/Database_Model.cs @@ -0,0 +1,27 @@ +using System; +using System.Data.Entity; +using System.Linq; +using Service_Server.Models; + +namespace Service_Server +{ + + + public class DATABASE : DbContext + { + + public DATABASE() : base("name=EHEC_DB"){} + public DbSet Persons { get; set; } + public DbSet PStatuses { get; set; } + public DbSet Doctors { get; set; } + public DbSet Origins { get; set; } + + + } + + //public class MyEntity + //{ + // public int Id { get; set; } + // public string Name { get; set; } + //} +} \ No newline at end of file diff --git a/Service_Server/Service_Server/DB/Doctor_DB.cs b/Service_Server/Service_Server/DB/Doctor_DB.cs new file mode 100644 index 0000000..a5e6fb6 --- /dev/null +++ b/Service_Server/Service_Server/DB/Doctor_DB.cs @@ -0,0 +1,73 @@ +using Service_Server.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +namespace Service_Server.DB +{ + class Doctor_DB + { + public List GetAllDoctors() + { + using (DATABASE ctx = new DATABASE()) + { + return ctx.Doctors.ToList(); + } + } + public bool CreateDoctor(Doctor doctor) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.Doctors.Add(doctor); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + + public bool UpdateDoctor(Doctor doctor) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.Doctors.Attach(doctor); + ctx.Entry(doctor).State = System.Data.Entity.EntityState.Modified; + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + + } + public bool DeleteDoctor(Doctor doctor) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.Doctors.Attach(doctor); + ctx.Doctors.Remove(doctor); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + } +} diff --git a/Service_Server/Service_Server/DB/Origin_DB.cs b/Service_Server/Service_Server/DB/Origin_DB.cs new file mode 100644 index 0000000..4ec9624 --- /dev/null +++ b/Service_Server/Service_Server/DB/Origin_DB.cs @@ -0,0 +1,72 @@ +using Service_Server.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service_Server.DB +{ + class Origin_DB + { + public List GetAllOrigins() + { + using (DATABASE ctx = new DATABASE()) + { + return ctx.Origins.ToList(); + } + } + public bool CreatePerson(Origin origin) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.Origins.Add(origin); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + + public bool UpdateOrigin(Origin origin) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.Origins.Attach(origin); + ctx.Entry(origin).State = System.Data.Entity.EntityState.Modified; + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + + } + public bool DeleteOrigin(Origin origin) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.Origins.Attach(origin); + ctx.Origins.Remove(origin); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + } +} diff --git a/Service_Server/Service_Server/DB/PStatus_DB.cs b/Service_Server/Service_Server/DB/PStatus_DB.cs new file mode 100644 index 0000000..a3bccec --- /dev/null +++ b/Service_Server/Service_Server/DB/PStatus_DB.cs @@ -0,0 +1,72 @@ +using Service_Server.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service_Server.DB +{ + class PStatus_DB + { + public List GetAllPstatuses() + { + using (DATABASE ctx = new DATABASE()) + { + return ctx.PStatuses.ToList(); + } + } + public bool CreatePstatus(PStatus pstatus) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.PStatuses.Add(pstatus); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + + public bool UpdatePstatus(PStatus pstatus) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.PStatuses.Attach(pstatus); + ctx.Entry(pstatus).State = System.Data.Entity.EntityState.Modified; + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + + } + public bool DeletePstatus(PStatus pstatus) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.PStatuses.Attach(pstatus); + ctx.PStatuses.Remove(pstatus); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + } +} diff --git a/Service_Server/Service_Server/DB/Person_DB.cs b/Service_Server/Service_Server/DB/Person_DB.cs new file mode 100644 index 0000000..83f308a --- /dev/null +++ b/Service_Server/Service_Server/DB/Person_DB.cs @@ -0,0 +1,72 @@ +using Service_Server.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service_Server.DB +{ + class Person_DB + { + public List GetAllPersons() + { + using (DATABASE ctx = new DATABASE()) + { + return ctx.Persons.ToList(); + } + } + public bool CreatePerson(Person person) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.Persons.Add(person); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + + public bool UpdatePerson(Person person) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.Persons.Attach(person); + ctx.Entry(person).State = System.Data.Entity.EntityState.Modified; + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + + } + public bool DeletePerson(Person person) + { + try + { + using (DATABASE ctx = new DATABASE()) + { + ctx.Persons.Attach(person); + ctx.Persons.Remove(person); + ctx.SaveChanges(); + } + return true; + } + catch (Exception) + { + return false; + } + } + } +} diff --git a/ServerWebApplication/ServerWebApplication/IService1.cs b/Service_Server/Service_Server/IService1.cs similarity index 51% rename from ServerWebApplication/ServerWebApplication/IService1.cs rename to Service_Server/Service_Server/IService1.cs index b1b8cd4..1902249 100644 --- a/ServerWebApplication/ServerWebApplication/IService1.cs +++ b/Service_Server/Service_Server/IService1.cs @@ -1,17 +1,27 @@ -using System; +using Service_Server.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; -namespace ServerWebApplication +namespace Service_Server { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together. [ServiceContract] public interface IService1 { [OperationContract] - void DoWork(); + void WritePatient(Person person); + [OperationContract] + void WriteExam(Exam exam); + [OperationContract] + void WriteResult(Result result); + [OperationContract] + List GetDoctors(); + + // TODO: Add your service operations here } + } diff --git a/Service_Server/Service_Server/Models/Doctor.cs b/Service_Server/Service_Server/Models/Doctor.cs new file mode 100644 index 0000000..9cf0532 --- /dev/null +++ b/Service_Server/Service_Server/Models/Doctor.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Service_Server.Models +{ + [DataContract] + public class Doctor : Person + { + private int _DoctorId; + + + [DataMember] + public int DoctorId { get => _DoctorId; set => _DoctorId = value; } + + + public Doctor() { } + public Doctor(string firstName, string lastName) + { + this.FirstName = firstName; + this.LastName = lastName; + + } + } +} diff --git a/Service_Server/Service_Server/Models/Exam.cs b/Service_Server/Service_Server/Models/Exam.cs new file mode 100644 index 0000000..d2f915c --- /dev/null +++ b/Service_Server/Service_Server/Models/Exam.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Service_Server.Models +{ + [DataContract] + public class Exam + { + private int _ExamId; + private DateTime _Date; + private Doctor _Doctor; + private Person _Patient; + private Result _Result; + + [DataMember] + public int ExamId { get => _ExamId; set => _ExamId = value; } + [DataMember] + public DateTime Date { get => _Date; set => _Date = value; } + [DataMember] + public virtual Doctor Doctor { get => _Doctor; set => _Doctor = value; } + [DataMember] + public virtual Person Patient { get => _Patient; set => _Patient = value; } + [DataMember] + public virtual Result Result { get => _Result; set => _Result = value; } + + public Exam() { } + public Exam(Doctor doctor, Person patient, Result result) + { + this.Date = DateTime.Now; + this.Doctor = doctor; + this.Patient = patient; + this.Result = result; + } + } +} diff --git a/Service_Server/Service_Server/Models/Origin.cs b/Service_Server/Service_Server/Models/Origin.cs new file mode 100644 index 0000000..95c6ac7 --- /dev/null +++ b/Service_Server/Service_Server/Models/Origin.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service_Server.Models +{ + class Origin + { + } +} diff --git a/Service_Server/Service_Server/Models/PStatus.cs b/Service_Server/Service_Server/Models/PStatus.cs new file mode 100644 index 0000000..f790b44 --- /dev/null +++ b/Service_Server/Service_Server/Models/PStatus.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Service_Server.Models +{ + [DataContract] + public class PStatus + { + private int _PStatusId; + private string _Name; + + [DataMember] + public int PStatusId { get => _PStatusId; set => _PStatusId = value; } + [DataMember] + public string Name { get => _Name; set => _Name = value; } + + public PStatus() { } + public PStatus(string name) + { + this.Name = name; + } + } +} diff --git a/Service_Server/Service_Server/Models/Person.cs b/Service_Server/Service_Server/Models/Person.cs new file mode 100644 index 0000000..000c8aa --- /dev/null +++ b/Service_Server/Service_Server/Models/Person.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Service_Server.Models +{ + [DataContract] + public class Person + { + private int _PersonId; + private string _FirstName; + private string _LastName; + private PStatus _PStatus; + + [DataMember] + public int PersonId { get => _PersonId; set => _PersonId = value; } + [DataMember] + public string FirstName { get => _FirstName; set => _FirstName = value; } + [DataMember] + public string LastName { get => _LastName; set => _LastName = value; } + [DataMember] + public virtual PStatus Status { get => _PStatus; set => _PStatus = value; } + + public Person() { } + public Person(string firstName, string lastName, PStatus pstatus) + { + this.FirstName = firstName; + this.LastName = lastName; + this.PStatus = pstatus; + } + } +} diff --git a/Service_Server/Service_Server/Models/Result.cs b/Service_Server/Service_Server/Models/Result.cs new file mode 100644 index 0000000..2fc62c0 --- /dev/null +++ b/Service_Server/Service_Server/Models/Result.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Service_Server.Models +{ + [DataContract] + public class Result + { + private int _ResultId; + private string _Name; + private string _Description; + private bool _Infected; + + [DataMember] + public int ResultId { get => _ResultId; set => _ResultId = value; } + [DataMember] + public string Name { get => _Name; set => _Name = value; } + [DataMember] + public string Description { get => _Description; set => _Description = value; } + [DataMember] + public bool Infected { get => _Infected; set => _Infected = value; } + + public Result() { } + public Result(string name, string description, bool infected) + { + this.Name = name; + this.Description = description; + this.Infected = infected; + } + } +} diff --git a/ServerWebApplication/ServerWebApplication/Properties/AssemblyInfo.cs b/Service_Server/Service_Server/Properties/AssemblyInfo.cs similarity index 80% rename from ServerWebApplication/ServerWebApplication/Properties/AssemblyInfo.cs rename to Service_Server/Service_Server/Properties/AssemblyInfo.cs index f0edc07..0cfc07a 100644 --- a/ServerWebApplication/ServerWebApplication/Properties/AssemblyInfo.cs +++ b/Service_Server/Service_Server/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("ServerWebApplication")] +[assembly: AssemblyTitle("Service_Server")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ServerWebApplication")] +[assembly: AssemblyProduct("Service_Server")] [assembly: AssemblyCopyright("Copyright © 2018")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("78d3b3d9-5cec-42d5-b3d1-c480e688fde1")] +[assembly: Guid("99603770-ad97-41c1-8868-744bceee2926")] // Version information for an assembly consists of the following four values: // @@ -29,7 +29,8 @@ using System.Runtime.InteropServices; // Build Number // Revision // -// You can specify all the values or you can default the Revision and Build Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Service_Server/Service_Server/Service1.cs b/Service_Server/Service_Server/Service1.cs new file mode 100644 index 0000000..54422da --- /dev/null +++ b/Service_Server/Service_Server/Service1.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.ServiceModel; +using System.Text; + +namespace Service_Server +{ + // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together. + public class Service1 : IService1 + { + public string GetData(int value) + { + return string.Format("You entered: {0}", value); + } + + public CompositeType GetDataUsingDataContract(CompositeType composite) + { + if (composite == null) + { + throw new ArgumentNullException("composite"); + } + if (composite.BoolValue) + { + composite.StringValue += "Suffix"; + } + return composite; + } + } +} diff --git a/Service_Server/Service_Server/Service_Server.csproj b/Service_Server/Service_Server/Service_Server.csproj new file mode 100644 index 0000000..ef98aeb --- /dev/null +++ b/Service_Server/Service_Server/Service_Server.csproj @@ -0,0 +1,100 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {99603770-AD97-41C1-8868-744BCEEE2926} + Library + Properties + Service_Server + Service_Server + {3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + /client:"WcfTestClient.exe" + v4.6.1 + True + True + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio + $(VSToolsPath)\WCF + + + + + + + True + + + + + + \ No newline at end of file diff --git a/Service_Server/Service_Server/packages.config b/Service_Server/Service_Server/packages.config new file mode 100644 index 0000000..373cff5 --- /dev/null +++ b/Service_Server/Service_Server/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file