From 30b0c9225cb8df154b7b57c24e08d4b25f059395 Mon Sep 17 00:00:00 2001 From: Daniel Gyulai Date: Thu, 19 Nov 2020 10:02:56 +0100 Subject: [PATCH] Added db initialization + extended public classes --- CoviDok/Api/Objects/PublicAssistant.cs | 3 ++- CoviDok/Api/Objects/PublicDoctor.cs | 5 +---- CoviDok/Api/Objects/PublicParent.cs | 1 + CoviDok/Data/Model/Assistant.cs | 18 +++++++++++++++--- CoviDok/Data/Model/Doctor.cs | 16 +++++++++++++--- CoviDok/Data/Model/Parent.cs | 15 ++++++++++++--- CoviDok/Data/Model/RoleUser.cs | 2 +- CoviDok/Data/Model/User.cs | 6 +----- CoviDok/Startup.cs | 4 ++++ 9 files changed, 50 insertions(+), 20 deletions(-) diff --git a/CoviDok/Api/Objects/PublicAssistant.cs b/CoviDok/Api/Objects/PublicAssistant.cs index e7a6610..b66a2af 100644 --- a/CoviDok/Api/Objects/PublicAssistant.cs +++ b/CoviDok/Api/Objects/PublicAssistant.cs @@ -8,10 +8,11 @@ namespace CoviDok.Api.Objects public class PublicAssistant { public string SessionID { get; set; } - public int DoctorId { get; set; } + public int? DoctorId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } public int ID { get; set; } + public string PictureID { get; set; } } } diff --git a/CoviDok/Api/Objects/PublicDoctor.cs b/CoviDok/Api/Objects/PublicDoctor.cs index 396ca33..0cd3e21 100644 --- a/CoviDok/Api/Objects/PublicDoctor.cs +++ b/CoviDok/Api/Objects/PublicDoctor.cs @@ -11,11 +11,8 @@ namespace CoviDok.Api.Objects public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } - + public string PictureID { get; set; } public string Email { get; set; } - public ICollection Children { get; set; } = new List(); - - public ICollection Assistants { get; set; } = new List(); } } diff --git a/CoviDok/Api/Objects/PublicParent.cs b/CoviDok/Api/Objects/PublicParent.cs index ebe9143..3866294 100644 --- a/CoviDok/Api/Objects/PublicParent.cs +++ b/CoviDok/Api/Objects/PublicParent.cs @@ -13,5 +13,6 @@ namespace CoviDok.Api.Objects public string LastName { get; set; } public string Email { get; set; } public ICollection Children { get; set; } = new List(); + public string PictureID { get; internal set; } } } diff --git a/CoviDok/Data/Model/Assistant.cs b/CoviDok/Data/Model/Assistant.cs index 4696955..ad7d82f 100644 --- a/CoviDok/Data/Model/Assistant.cs +++ b/CoviDok/Data/Model/Assistant.cs @@ -8,15 +8,27 @@ namespace CoviDok.Data.Model { public class Assistant : RoleUser { - public int DoctorId { get; set; } + public int? DoctorId { get; set; } public void UpdateSelf(PublicAssistant assistant) { - + FirstName = assistant.FirstName; + LastName = assistant.LastName; + Email = assistant.Email; + PictureId = assistant.PictureID; + DoctorId = assistant.DoctorId; } public PublicAssistant ToPublic() { - throw new NotImplementedException(); + return new PublicAssistant + { + FirstName = FirstName, + LastName = LastName, + Email = Email, + PictureID = PictureId, + ID = Id, + DoctorId = DoctorId + }; } } } diff --git a/CoviDok/Data/Model/Doctor.cs b/CoviDok/Data/Model/Doctor.cs index b92b9f6..6d4bcef 100644 --- a/CoviDok/Data/Model/Doctor.cs +++ b/CoviDok/Data/Model/Doctor.cs @@ -12,12 +12,22 @@ namespace CoviDok.Data.Model public ICollection Assistants { get; set; } = new List(); - public void UpdateSelf(PublicDoctor doctor) { - + public void UpdateSelf(PublicDoctor doctor) { + FirstName = doctor.FirstName; + LastName = doctor.LastName; + Email = doctor.Email; + PictureId = doctor.PictureID; } public PublicDoctor ToPublic() { - throw new NotImplementedException(); + return new PublicDoctor + { + FirstName = FirstName, + LastName = LastName, + Email = Email, + PictureID = PictureId, + ID = Id + }; } } diff --git a/CoviDok/Data/Model/Parent.cs b/CoviDok/Data/Model/Parent.cs index 0d4002b..9db47c9 100644 --- a/CoviDok/Data/Model/Parent.cs +++ b/CoviDok/Data/Model/Parent.cs @@ -10,13 +10,22 @@ namespace CoviDok.Data.Model { public ICollection Children { get; set; } = new List(); - public void UpdateSelf(PublicParent doctor) + public void UpdateSelf(PublicParent parent) { - + FirstName = parent.FirstName; + LastName = parent.LastName; + Email = parent.Email; + PictureId = parent.PictureID; } public PublicParent ToPublic() { - throw new NotImplementedException(); + return new PublicParent { + FirstName = FirstName, + LastName = LastName, + Email = Email, + PictureID = PictureId, + ID = Id + }; } } } diff --git a/CoviDok/Data/Model/RoleUser.cs b/CoviDok/Data/Model/RoleUser.cs index 562ca97..78411d9 100644 --- a/CoviDok/Data/Model/RoleUser.cs +++ b/CoviDok/Data/Model/RoleUser.cs @@ -13,7 +13,7 @@ namespace CoviDok.Data.Model public Role Role { get; set; } public string Email { get; set; } - + public string Password { get; set; } private static byte[] GetHash(string inputString) { diff --git a/CoviDok/Data/Model/User.cs b/CoviDok/Data/Model/User.cs index cc54373..6bb7986 100644 --- a/CoviDok/Data/Model/User.cs +++ b/CoviDok/Data/Model/User.cs @@ -15,9 +15,5 @@ namespace CoviDok.Data.Model public DateTime RegistrationDate { get; set; } public string PictureId { get; set; } - - - } - - + } } diff --git a/CoviDok/Startup.cs b/CoviDok/Startup.cs index 591f002..31d16d0 100644 --- a/CoviDok/Startup.cs +++ b/CoviDok/Startup.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using CoviDok.Data.MySQL; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -32,6 +33,9 @@ namespace CoviDok app.UseMvc(); + MySqlContext ctx = new MySqlContext(); + ctx.Database.EnsureCreated(); + //app.UseEndpoints(endpoints => //{ // endpoints.MapGet("/", async context =>