diff --git a/Hospital/HospitalBusinessLogic/BusinessLogics/DoctorLogic.cs b/Hospital/HospitalBusinessLogic/BusinessLogics/DoctorLogic.cs index e568222..03b901a 100644 --- a/Hospital/HospitalBusinessLogic/BusinessLogics/DoctorLogic.cs +++ b/Hospital/HospitalBusinessLogic/BusinessLogics/DoctorLogic.cs @@ -113,7 +113,7 @@ namespace HospitalBusinessLogic.BusinessLogics var element = _doctorStorage.GetElement(new DoctorSearchModel { Login = model.Login, - PhoneNumber = model.PhoneNumber, + Password = model.Password }); if (element != null && element.Id != model.Id) { diff --git a/Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs b/Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs index e908a59..d583b17 100644 --- a/Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs +++ b/Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs @@ -26,7 +26,7 @@ namespace HospitalBusinessLogic.BusinessLogics } public List? ReadList(PharmacistSearchModel? model) { - _logger.LogInformation("ReadList. PharmacistFIO:{PharmacistFIO}. Id:{ Id}", model?.FIO, model?.Id); + _logger.LogInformation("ReadList. FIO:{FIO}. Id:{ Id}", model?.FIO, model?.Id); var list = model == null ? _pharmacistStorage.GetFullList() : _pharmacistStorage.GetFilteredList(model); if (list == null) @@ -43,7 +43,7 @@ namespace HospitalBusinessLogic.BusinessLogics { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. PharmacistFIO:{PharmacistFIO}.Id:{ Id}", model.FIO, model.Id); + _logger.LogInformation("ReadElement. FIO:{FIO}.Id:{ Id}", model.FIO, model.Id); var element = _pharmacistStorage.GetElement(model); if (element == null) { @@ -110,7 +110,7 @@ namespace HospitalBusinessLogic.BusinessLogics throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password)); } - _logger.LogInformation("Pharmacist. PharmacistFIO:{PharmacistFIO}." + + _logger.LogInformation("Pharmacist. FIO:{FIO}." + "Email:{ Email}. Password:{ Password}. Id: { Id} ", model.FIO, model.Login, model.Password, model.Id); var element = _pharmacistStorage.GetElement(new PharmacistSearchModel { diff --git a/Hospital/HospitalBusinessLogic/BusinessLogics/RecipeLogic.cs b/Hospital/HospitalBusinessLogic/BusinessLogics/RecipeLogic.cs index 5fa5cf4..8024441 100644 --- a/Hospital/HospitalBusinessLogic/BusinessLogics/RecipeLogic.cs +++ b/Hospital/HospitalBusinessLogic/BusinessLogics/RecipeLogic.cs @@ -97,10 +97,10 @@ namespace HospitalBusinessLogic.BusinessLogics { return; } - if (model.RecipeMedicines == null || model.RecipeMedicines.Count == 0) + /*if (model.RecipeMedicines == null || model.RecipeMedicines.Count == 0) { throw new ArgumentNullException("Нет лекарств в рецепте", nameof(model.RecipeMedicines)); - } + }TODO*/ _logger.LogInformation("Recipe. Id:{ Id}. DiseaseId:{DiseaseId}. DoctorId:{DoctorId}", model.Id, model.DiseaseId, model.DoctorId); var element = _recipeStorage.GetElement(new RecipeSearchModel { diff --git a/Hospital/HospitalContracts/BindingModels/DescriptionProcedureBindingModel.cs b/Hospital/HospitalContracts/BindingModels/DescriptionProcedureBindingModel.cs index a053bbb..5034696 100644 --- a/Hospital/HospitalContracts/BindingModels/DescriptionProcedureBindingModel.cs +++ b/Hospital/HospitalContracts/BindingModels/DescriptionProcedureBindingModel.cs @@ -9,10 +9,11 @@ namespace HospitalContracts.BindingModels { public class DescriptionProcedureBindingModel : IDescriptionProcedureModel { - public string Description { get; set; } = string.Empty; + public int Id { get; set; } + public string Description { get; set; } = string.Empty; public int PharmacistId { get; set; } - public int Id { get; set; } + } } diff --git a/Hospital/HospitalContracts/BindingModels/MedicineBindingModel.cs b/Hospital/HospitalContracts/BindingModels/MedicineBindingModel.cs index 13349f7..7c4734b 100644 --- a/Hospital/HospitalContracts/BindingModels/MedicineBindingModel.cs +++ b/Hospital/HospitalContracts/BindingModels/MedicineBindingModel.cs @@ -10,11 +10,12 @@ namespace HospitalContracts.BindingModels { public class MedicineBindingModel : IMedicineModel { - public string Name { get; set; } = string.Empty; + public int Id { get; set; } + public string Name { get; set; } = string.Empty; public string CountryOrigin { get; set; } = string.Empty; public double Price { get; set; } - public int Id { get; set; } public int PharmacistId { get; set; } - - } + public Dictionary MedicineRecipes { get; set; } = new(); + + } } diff --git a/Hospital/HospitalContracts/BindingModels/PatientBindingModel.cs b/Hospital/HospitalContracts/BindingModels/PatientBindingModel.cs index 715fe48..d0abf50 100644 --- a/Hospital/HospitalContracts/BindingModels/PatientBindingModel.cs +++ b/Hospital/HospitalContracts/BindingModels/PatientBindingModel.cs @@ -21,6 +21,5 @@ namespace HospitalContracts.BindingModels public Dictionary PatientProcedures { get; set; } = new(); - public Dictionary PatientRecipes { get; set; } = new(); } } diff --git a/Hospital/HospitalContracts/BindingModels/ProcedureBindingModel.cs b/Hospital/HospitalContracts/BindingModels/ProcedureBindingModel.cs index 8e06f9e..aa86cb1 100644 --- a/Hospital/HospitalContracts/BindingModels/ProcedureBindingModel.cs +++ b/Hospital/HospitalContracts/BindingModels/ProcedureBindingModel.cs @@ -10,17 +10,17 @@ namespace HospitalContracts.BindingModels public class ProcedureBindingModel : IProcedureModel { - public string Name { get; set; } = string.Empty; - + public int Id { get; set; } + public string Name { get; set; } = string.Empty; public DateTime Date { get; set; } public int DescriptionProcedureId { get; set; } public int PharmacistId { get; set; } - public int Id { get; set; } + public Dictionary ProcedureMedicines { get; set; } = new(); - } - } + } +} diff --git a/Hospital/HospitalContracts/BindingModels/RecipeBindingModel.cs b/Hospital/HospitalContracts/BindingModels/RecipeBindingModel.cs index a7243d9..ed88798 100644 --- a/Hospital/HospitalContracts/BindingModels/RecipeBindingModel.cs +++ b/Hospital/HospitalContracts/BindingModels/RecipeBindingModel.cs @@ -18,6 +18,6 @@ namespace HospitalContracts.BindingModels public int DoctorId { get; set; } - public Dictionary RecipeMedicines { get; set; } = new(); + public Dictionary RecipePatients { get; set; } = new(); } } diff --git a/Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs b/Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs index 578c0fb..b4e7e1c 100644 --- a/Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs +++ b/Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs @@ -11,5 +11,6 @@ namespace HospitalContracts.SearchModels public int? Id { get; set; } public int? DoctorId { get; set; } - } + DateTime IssueDate { get; } + } } diff --git a/Hospital/HospitalContracts/ViewModels/DescriptionProcedureViewModel.cs b/Hospital/HospitalContracts/ViewModels/DescriptionProcedureViewModel.cs index 0bb1923..f38f5f6 100644 --- a/Hospital/HospitalContracts/ViewModels/DescriptionProcedureViewModel.cs +++ b/Hospital/HospitalContracts/ViewModels/DescriptionProcedureViewModel.cs @@ -16,5 +16,7 @@ namespace HospitalContracts.ViewModels [DisplayName("Фармацевт")] public int PharmacistId { get; set; } - } + + + } } diff --git a/Hospital/HospitalContracts/ViewModels/MedicineViewModel.cs b/Hospital/HospitalContracts/ViewModels/MedicineViewModel.cs index 73ffa42..46e9d13 100644 --- a/Hospital/HospitalContracts/ViewModels/MedicineViewModel.cs +++ b/Hospital/HospitalContracts/ViewModels/MedicineViewModel.cs @@ -20,6 +20,8 @@ namespace HospitalContracts.ViewModels [DisplayName("Фармацевт")] public int PharmacistId { get; set; } - - } + + public Dictionary MedicineRecipes { get; set; } = new(); + + } } diff --git a/Hospital/HospitalContracts/ViewModels/PatientViewModel.cs b/Hospital/HospitalContracts/ViewModels/PatientViewModel.cs index a4ca970..43739a8 100644 --- a/Hospital/HospitalContracts/ViewModels/PatientViewModel.cs +++ b/Hospital/HospitalContracts/ViewModels/PatientViewModel.cs @@ -10,7 +10,8 @@ namespace HospitalContracts.ViewModels { public class PatientViewModel : IPatientModel { - public int Id { get; set; } + [DisplayName("Номер")] + public int Id { get; set; } [DisplayName("ФИО")] public string FIO { get; set; } = string.Empty; @@ -25,7 +26,7 @@ namespace HospitalContracts.ViewModels public Dictionary PatientProcedures { get; set; } = new(); - public Dictionary PatientRecipes { get; set; } = new(); + } } diff --git a/Hospital/HospitalContracts/ViewModels/ProcedureViewModel.cs b/Hospital/HospitalContracts/ViewModels/ProcedureViewModel.cs index a3fecec..8a99a6c 100644 --- a/Hospital/HospitalContracts/ViewModels/ProcedureViewModel.cs +++ b/Hospital/HospitalContracts/ViewModels/ProcedureViewModel.cs @@ -16,7 +16,7 @@ namespace HospitalContracts.ViewModels [DisplayName("Дата процедуры")] public DateTime Date { get; set; } [DisplayName("Фармацевт")] - //public string PharmacistFIO { get; set; } = string.Empty; + public int PharmacistId { get; set; } [DisplayName("Описание процедуры")] public int DescriptionProcedureId { get; set; } diff --git a/Hospital/HospitalContracts/ViewModels/RecipeViewModel.cs b/Hospital/HospitalContracts/ViewModels/RecipeViewModel.cs index be4e2c5..33dc831 100644 --- a/Hospital/HospitalContracts/ViewModels/RecipeViewModel.cs +++ b/Hospital/HospitalContracts/ViewModels/RecipeViewModel.cs @@ -9,7 +9,8 @@ namespace HospitalContracts.ViewModels { public class RecipeViewModel : IRecipeModel { - public string Description { get; set; } = string.Empty; + public int Id { get; set; } + public string Description { get; set; } = string.Empty; public DateTime IssueDate { get; set; } = DateTime.Now; @@ -17,8 +18,8 @@ namespace HospitalContracts.ViewModels public int DoctorId { get; set; } - public Dictionary RecipeMedicines { get; set; } = new(); + public Dictionary RecipePatients { get; set; } = new(); - public int Id { get; set; } + } } diff --git a/Hospital/HospitalDataBaseImplement/Implementss/DescriptionProcedureStorage.cs b/Hospital/HospitalDataBaseImplement/Implementss/DescriptionProcedureStorage.cs index 8ce5dda..73a4149 100644 --- a/Hospital/HospitalDataBaseImplement/Implementss/DescriptionProcedureStorage.cs +++ b/Hospital/HospitalDataBaseImplement/Implementss/DescriptionProcedureStorage.cs @@ -67,12 +67,13 @@ namespace HospitalDatabaseImplement.Implements public DescriptionProcedureViewModel? Insert(DescriptionProcedureBindingModel model) { - var newDisease = DescriptionProcedure.Create(model); + using var context = new HospitalDatabase(); + var newDisease = DescriptionProcedure.Create(context, model); if (newDisease == null) { return null; } - using var context = new HospitalDatabase(); + context.DescriptionProcedures.Add(newDisease); context.SaveChanges(); return context.DescriptionProcedures @@ -90,7 +91,7 @@ namespace HospitalDatabaseImplement.Implements { return null; } - disease.Update(model); + disease.Update(context, model); context.SaveChanges(); return context.DescriptionProcedures .Include(x => x.Procedures) diff --git a/Hospital/HospitalDataBaseImplement/Implementss/MedicineStorage.cs b/Hospital/HospitalDataBaseImplement/Implementss/MedicineStorage.cs index 0390fdd..e5c062b 100644 --- a/Hospital/HospitalDataBaseImplement/Implementss/MedicineStorage.cs +++ b/Hospital/HospitalDataBaseImplement/Implementss/MedicineStorage.cs @@ -52,7 +52,7 @@ namespace HospitalDatabaseImplement.Implements public MedicineViewModel? Insert(MedicineBindingModel model) { using var context = new HospitalDatabase(); - var newMedicine = Medicine.Create(model); + var newMedicine = Medicine.Create(context, model); if (newMedicine == null) { return null; diff --git a/Hospital/HospitalDataBaseImplement/Models/DescriptionProcedure.cs b/Hospital/HospitalDataBaseImplement/Models/DescriptionProcedure.cs index f459973..deab2d4 100644 --- a/Hospital/HospitalDataBaseImplement/Models/DescriptionProcedure.cs +++ b/Hospital/HospitalDataBaseImplement/Models/DescriptionProcedure.cs @@ -28,7 +28,7 @@ namespace HospitalDatabaseImplement.Models [ForeignKey("IDescriptionProcedureId")] public virtual List Procedures { get; set; } = new(); - public static DescriptionProcedure? Create(DescriptionProcedureBindingModel model) + public static DescriptionProcedure? Create(HospitalDatabase context, DescriptionProcedureBindingModel model) { if (model == null) { @@ -37,33 +37,31 @@ namespace HospitalDatabaseImplement.Models return new DescriptionProcedure() { Id = model.Id, - Description = model.Description, - PharmacistId = model.PharmacistId - }; + + + Description = model.Description, + PharmacistId = model.PharmacistId, + Pharmacist = context.Pharmacists.FirstOrDefault(x => x.Id == model.PharmacistId) + }; } - public static DescriptionProcedure Create(DescriptionProcedureViewModel model) - { - return new DescriptionProcedure - { - Id = model.Id, - Description = model.Description - }; - } - - public void Update(DescriptionProcedureBindingModel model) + public void Update(HospitalDatabase context, DescriptionProcedureBindingModel model) { if (model == null) { return; } Description = model.Description; - } + PharmacistId = model.PharmacistId; + Pharmacist = context.Pharmacists.FirstOrDefault(x => x.Id == model.PharmacistId); + + } public DescriptionProcedureViewModel GetViewModel => new() { Id = Id, - Description = Description + Description = Description, + PharmacistId = PharmacistId }; } } diff --git a/Hospital/HospitalDataModels/Models/IDescriptionProcedureModel.cs b/Hospital/HospitalDataModels/Models/IDescriptionProcedureModel.cs index bda3cf7..a825660 100644 --- a/Hospital/HospitalDataModels/Models/IDescriptionProcedureModel.cs +++ b/Hospital/HospitalDataModels/Models/IDescriptionProcedureModel.cs @@ -7,10 +7,10 @@ using System.Threading.Tasks; namespace HospitalDataModels.Models { - public interface IDescriptionProcedureModel + public interface IDescriptionProcedureModel : IId { string Description { get; } int PharmacistId { get; } - } + } } diff --git a/Hospital/HospitalDataModels/Models/IDiseaseModel.cs b/Hospital/HospitalDataModels/Models/IDiseaseModel.cs index e471b49..f22c9b8 100644 --- a/Hospital/HospitalDataModels/Models/IDiseaseModel.cs +++ b/Hospital/HospitalDataModels/Models/IDiseaseModel.cs @@ -6,11 +6,10 @@ using System.Threading.Tasks; namespace HospitalDataModels.Models { - public interface IDiseaseModel + public interface IDiseaseModel : IId { - string Name { get; } + string Name { get; } string Description { get; } int DoctorId { get; } - } } diff --git a/Hospital/HospitalDataModels/Models/IMedicineModel.cs b/Hospital/HospitalDataModels/Models/IMedicineModel.cs index 8dd96e7..f30b8c9 100644 --- a/Hospital/HospitalDataModels/Models/IMedicineModel.cs +++ b/Hospital/HospitalDataModels/Models/IMedicineModel.cs @@ -12,6 +12,7 @@ namespace HospitalDataModels.Models string CountryOrigin { get; } double Price { get; } int PharmacistId { get; } - - } + Dictionary MedicineRecipes { get; } + + } } diff --git a/Hospital/HospitalDataModels/Models/IPatientModel.cs b/Hospital/HospitalDataModels/Models/IPatientModel.cs index 67783c5..4c80ab4 100644 --- a/Hospital/HospitalDataModels/Models/IPatientModel.cs +++ b/Hospital/HospitalDataModels/Models/IPatientModel.cs @@ -14,6 +14,5 @@ namespace HospitalDataModels.Models int DoctorId { get; } Dictionary PatientProcedures { get; } - Dictionary PatientRecipes { get; } } } diff --git a/Hospital/HospitalDataModels/Models/IRecipeModel.cs b/Hospital/HospitalDataModels/Models/IRecipeModel.cs index fbffe3b..655a019 100644 --- a/Hospital/HospitalDataModels/Models/IRecipeModel.cs +++ b/Hospital/HospitalDataModels/Models/IRecipeModel.cs @@ -16,6 +16,6 @@ namespace HospitalDataModels.Models int DoctorId { get; } - Dictionary RecipeMedicines { get; } + Dictionary RecipePatients { get; } } } diff --git a/Hospital/HospitalDatabaseImplement/Implementss/DoctorStorage.cs b/Hospital/HospitalDatabaseImplement/Implementss/DoctorStorage.cs index fb5018a..3a76587 100644 --- a/Hospital/HospitalDatabaseImplement/Implementss/DoctorStorage.cs +++ b/Hospital/HospitalDatabaseImplement/Implementss/DoctorStorage.cs @@ -16,18 +16,18 @@ namespace HospitalDatabaseImplement.Implementss { public DoctorViewModel? GetElement(DoctorSearchModel model) { - if (!model.Id.HasValue) + if ((string.IsNullOrEmpty(model.Login) && !model.Id.HasValue)) { return null; } using var context = new HospitalDatabase(); + return context.Doctors - .Include(x => x.Recipes) - .Include(x => x.Diseases) - .Include(x => x.Patients) - .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) - ?.GetViewModel; - } + .FirstOrDefault(x => + (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Login) || x.Login == model.Login) && + (string.IsNullOrEmpty(model.Password) || x.Password == model.Password)) + ?.GetViewModel; + } public List GetFilteredList(DoctorSearchModel model) { diff --git a/Hospital/HospitalDatabaseImplement/Implementss/PatientStorage.cs b/Hospital/HospitalDatabaseImplement/Implementss/PatientStorage.cs index 4f6fcb6..ccc0db6 100644 --- a/Hospital/HospitalDatabaseImplement/Implementss/PatientStorage.cs +++ b/Hospital/HospitalDatabaseImplement/Implementss/PatientStorage.cs @@ -92,7 +92,7 @@ namespace HospitalDatabaseImplement.Implementss } patient.Update(model); context.SaveChanges(); - patient.UpdateRecipes(context, model); + patient.UpdateProcedures(context, model); transaction.Commit(); return patient.GetViewModel; } diff --git a/Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs b/Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs index 3e79556..2b28925 100644 --- a/Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs +++ b/Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs @@ -30,8 +30,8 @@ namespace HospitalDatabaseImplement.Implementss { return context.Recipes .Include(x => x.Doctor) - .Include(x => x.Medicines) - .ThenInclude(x => x.Medicine) + .Include(x => x.Patients) + .ThenInclude(x => x.Patient) .Where(x => x.Id == model.Id).ToList() .Select(x => x.GetViewModel).ToList(); } @@ -39,8 +39,8 @@ namespace HospitalDatabaseImplement.Implementss { return context.Recipes .Include(x => x.Doctor) - .Include(x => x.Medicines) - .ThenInclude(x => x.Medicine) + .Include(x => x.Patients) + .ThenInclude(x => x.Patient) .Where(x => x.DoctorId == model.DoctorId) .Select(x => x.GetViewModel).ToList(); } @@ -59,8 +59,8 @@ namespace HospitalDatabaseImplement.Implementss using var context = new HospitalDatabase(); return context.Recipes .Include(x => x.Doctor) - .Include(x => x.Medicines) - .ThenInclude(x => x.Medicine) + .Include(x => x.Patients) + .ThenInclude(x => x.Patient) .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) ?.GetViewModel; } @@ -94,7 +94,7 @@ namespace HospitalDatabaseImplement.Implementss } recipe.Update(model); context.SaveChanges(); - recipe.UpdateMedicines(context, model); + recipe.UpdatePatients(context, model); transaction.Commit(); return recipe.GetViewModel; } @@ -109,7 +109,7 @@ namespace HospitalDatabaseImplement.Implementss using var context = new HospitalDatabase(); var element = context.Recipes .Include(x => x.Doctor) - .Include(x => x.Medicines) + .Include(x => x.Patients) .FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { diff --git a/Hospital/HospitalDatabaseImplement/Migrations/20240429163909_InitialCreate.Designer.cs b/Hospital/HospitalDatabaseImplement/Migrations/20240430102720_InitCreate.Designer.cs similarity index 98% rename from Hospital/HospitalDatabaseImplement/Migrations/20240429163909_InitialCreate.Designer.cs rename to Hospital/HospitalDatabaseImplement/Migrations/20240430102720_InitCreate.Designer.cs index 5e137eb..0e6160f 100644 --- a/Hospital/HospitalDatabaseImplement/Migrations/20240429163909_InitialCreate.Designer.cs +++ b/Hospital/HospitalDatabaseImplement/Migrations/20240430102720_InitCreate.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace HospitalDatabaseImplement.Migrations { [DbContext(typeof(HospitalDatabase))] - [Migration("20240429163909_InitialCreate")] - partial class InitialCreate + [Migration("20240430102720_InitCreate")] + partial class InitCreate { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -436,7 +436,7 @@ namespace HospitalDatabaseImplement.Migrations .IsRequired(); b.HasOne("HospitalDatabaseImplement.Modelss.Recipe", "Recipe") - .WithMany() + .WithMany("Patients") .HasForeignKey("RecipeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -468,7 +468,7 @@ namespace HospitalDatabaseImplement.Migrations modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b => { b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine") - .WithMany() + .WithMany("Services") .HasForeignKey("MedicineId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -487,13 +487,13 @@ namespace HospitalDatabaseImplement.Migrations modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b => { b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine") - .WithMany("RecipeMedicines") + .WithMany("Recipes") .HasForeignKey("MedicineId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("HospitalDatabaseImplement.Modelss.Recipe", "Recipe") - .WithMany("Medicines") + .WithMany() .HasForeignKey("RecipeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -543,7 +543,9 @@ namespace HospitalDatabaseImplement.Migrations modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b => { - b.Navigation("RecipeMedicines"); + b.Navigation("Recipes"); + + b.Navigation("Services"); }); modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b => @@ -571,7 +573,7 @@ namespace HospitalDatabaseImplement.Migrations modelBuilder.Entity("HospitalDatabaseImplement.Modelss.Recipe", b => { - b.Navigation("Medicines"); + b.Navigation("Patients"); }); #pragma warning restore 612, 618 } diff --git a/Hospital/HospitalDatabaseImplement/Migrations/20240429163909_InitialCreate.cs b/Hospital/HospitalDatabaseImplement/Migrations/20240430102720_InitCreate.cs similarity index 96% rename from Hospital/HospitalDatabaseImplement/Migrations/20240429163909_InitialCreate.cs rename to Hospital/HospitalDatabaseImplement/Migrations/20240430102720_InitCreate.cs index a5f2ef1..e81a2f2 100644 --- a/Hospital/HospitalDatabaseImplement/Migrations/20240429163909_InitialCreate.cs +++ b/Hospital/HospitalDatabaseImplement/Migrations/20240430102720_InitCreate.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace HospitalDatabaseImplement.Migrations { /// - public partial class InitialCreate : Migration + public partial class InitCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -153,8 +153,8 @@ namespace HospitalDatabaseImplement.Migrations name: "FK_Recipes_Doctors_DoctorId", column: x => x.DoctorId, principalTable: "Doctors", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id" + ); }); migrationBuilder.CreateTable( @@ -166,14 +166,15 @@ namespace HospitalDatabaseImplement.Migrations Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), Date = table.Column(type: "datetime2", nullable: false), DescriptionProcedureId = table.Column(type: "int", nullable: false), + IDescriptionProcedureId = table.Column(type: "int", nullable: false), PharmacistId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Procedures", x => x.Id); table.ForeignKey( - name: "FK_Procedures_DescriptionProcedures_DescriptionProcedureId", - column: x => x.DescriptionProcedureId, + name: "FK_Procedures_DescriptionProcedures_IDescriptionProcedureId", + column: x => x.IDescriptionProcedureId, principalTable: "DescriptionProcedures", principalColumn: "Id", onDelete: ReferentialAction.Cascade); @@ -181,8 +182,8 @@ namespace HospitalDatabaseImplement.Migrations name: "FK_Procedures_Pharmacists_PharmacistId", column: x => x.PharmacistId, principalTable: "Pharmacists", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id" + ); }); migrationBuilder.CreateTable( @@ -207,8 +208,8 @@ namespace HospitalDatabaseImplement.Migrations name: "FK_PatientRecipes_Recipes_RecipeId", column: x => x.RecipeId, principalTable: "Recipes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id" + ); }); migrationBuilder.CreateTable( @@ -285,8 +286,8 @@ namespace HospitalDatabaseImplement.Migrations name: "FK_ProcedureMedicines_Procedures_ProcedureId", column: x => x.ProcedureId, principalTable: "Procedures", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id" + ); }); migrationBuilder.CreateIndex( diff --git a/Hospital/HospitalDatabaseImplement/Migrations/HospitalDatabaseModelSnapshot.cs b/Hospital/HospitalDatabaseImplement/Migrations/HospitalDatabaseModelSnapshot.cs index 551a34c..3611c63 100644 --- a/Hospital/HospitalDatabaseImplement/Migrations/HospitalDatabaseModelSnapshot.cs +++ b/Hospital/HospitalDatabaseImplement/Migrations/HospitalDatabaseModelSnapshot.cs @@ -433,7 +433,7 @@ namespace HospitalDatabaseImplement.Migrations .IsRequired(); b.HasOne("HospitalDatabaseImplement.Modelss.Recipe", "Recipe") - .WithMany() + .WithMany("Patients") .HasForeignKey("RecipeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -465,7 +465,7 @@ namespace HospitalDatabaseImplement.Migrations modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b => { b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine") - .WithMany() + .WithMany("Services") .HasForeignKey("MedicineId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -484,13 +484,13 @@ namespace HospitalDatabaseImplement.Migrations modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b => { b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine") - .WithMany("RecipeMedicines") + .WithMany("Recipes") .HasForeignKey("MedicineId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("HospitalDatabaseImplement.Modelss.Recipe", "Recipe") - .WithMany("Medicines") + .WithMany() .HasForeignKey("RecipeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -540,7 +540,9 @@ namespace HospitalDatabaseImplement.Migrations modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b => { - b.Navigation("RecipeMedicines"); + b.Navigation("Recipes"); + + b.Navigation("Services"); }); modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b => @@ -568,7 +570,7 @@ namespace HospitalDatabaseImplement.Migrations modelBuilder.Entity("HospitalDatabaseImplement.Modelss.Recipe", b => { - b.Navigation("Medicines"); + b.Navigation("Patients"); }); #pragma warning restore 612, 618 } diff --git a/Hospital/HospitalDatabaseImplement/Models/Doctor.cs b/Hospital/HospitalDatabaseImplement/Models/Doctor.cs index 3a04347..7baf5ab 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Doctor.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Doctor.cs @@ -53,7 +53,7 @@ namespace HospitalDatabaseImplement.Models } return new Doctor() { - Id = model.Id, + //Id = model.Id, Login = model.Login, PhoneNumber = model.PhoneNumber, Password = model.Password, diff --git a/Hospital/HospitalDatabaseImplement/Models/Medicine.cs b/Hospital/HospitalDatabaseImplement/Models/Medicine.cs index ee2196b..0925c91 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Medicine.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Medicine.cs @@ -14,12 +14,11 @@ namespace HospitalDatabaseImplement.Models { public class Medicine : IMedicineModel { - - public int Id { get; set; } + public int Id { get; set; } - [Required] - [MaxLength(50)] - public string Name { get; set; } = string.Empty; + [Required] + [MaxLength(50)] + public string Name { get; set; } = string.Empty; [Required] @@ -29,45 +28,87 @@ namespace HospitalDatabaseImplement.Models public double Price { get; set; } public int PharmacistId { get; private set; } - public virtual Pharmacist Pharmacist { get; set; } - [ForeignKey("MedicineId")] - public virtual List RecipeMedicines { get; set; } = new(); + private Dictionary? _medicineRecipes = + null; + + [NotMapped] + public Dictionary MedicineRecipes + { + get + { + if (_medicineRecipes == null) + { + _medicineRecipes = Recipes + .ToDictionary(recPC => recPC.RecipeId, recPC => + recPC.Recipe as IRecipeModel); + } + return _medicineRecipes; + } + } - public static Medicine? Create(MedicineBindingModel model) - { - if (model == null) - { - return null; - } - return new Medicine() - { - Id = model.Id, - Name = model.Name - }; - } - public static Medicine Create(MedicineViewModel model) - { - return new Medicine - { - Id = model.Id, - Name = model.Name - }; - } - public void Update(MedicineBindingModel model) - { - if (model == null) - { - return; - } - Name = model.Name; - } - public MedicineViewModel GetViewModel => new() - { - Id = Id, - Name = Name - }; - - } + [ForeignKey("MedicineId")] + public virtual List Recipes { get; set; } = new(); + [ForeignKey("MedicineId")] + public virtual List Services { get; set; } = new(); + public static Medicine Create(HospitalDatabase context, + MedicineBindingModel model) + { + return new Medicine() + { + Id = model.Id, + Name = model.Name, + Price = model.Price, + Recipes = model.MedicineRecipes.Select(x => new + RecipeMedicine + { + Recipe = context.Recipes.First(y => y.Id == x.Key), + }).ToList(), + PharmacistId = model.PharmacistId, + Pharmacist = context.Pharmacists.First(x => x.Id == model.PharmacistId) + }; + } + public void Update(MedicineBindingModel model) + { + Name = model.Name; + Price = model.Price; + } + public MedicineViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + Price = Price, + MedicineRecipes = MedicineRecipes, + }; + public void UpdateRecipes(HospitalDatabase context, + MedicineBindingModel model) + { + if (model.MedicineRecipes == null) + return; + var medicineRecipes = context.RecipeMedicines.Where(rec => + rec.MedicineId == model.Id).ToList(); + if (medicineRecipes != null && medicineRecipes.Count > 0) + { + context.RecipeMedicines.RemoveRange(medicineRecipes.Where(rec +=> !model.MedicineRecipes.ContainsKey(rec.RecipeId))); + foreach (var recipe in medicineRecipes) + { + model.MedicineRecipes.Remove(recipe.RecipeId); + } + context.SaveChanges(); + } + var medicine = context.Medicines.First(x => x.Id == Id); + foreach (var pc in model.MedicineRecipes) + { + context.RecipeMedicines.Add(new RecipeMedicine + { + Medicine = medicine, + Recipe = context.Recipes.First(x => x.Id == pc.Key), + }); + context.SaveChanges(); + } + _medicineRecipes = null; + } + } } \ No newline at end of file diff --git a/Hospital/HospitalDatabaseImplement/Models/Patient.cs b/Hospital/HospitalDatabaseImplement/Models/Patient.cs index 28b7054..ac46c49 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Patient.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Patient.cs @@ -14,8 +14,8 @@ namespace HospitalDatabaseImplement.Models public class Patient : IPatientModel { public int Id { get; set; } - - public int DoctorId { get; private set; } + [Required] + public int DoctorId { get; private set; } public virtual Doctor Doctor { get; set; } @@ -32,7 +32,13 @@ namespace HospitalDatabaseImplement.Models private Dictionary? _patientRecipes = null; - [NotMapped] + [ForeignKey("PatientId")] + public virtual List Procedures { get; set; } = new(); + [ForeignKey("PatientId")] + public virtual List Recipes { get; set; } = new(); + + + /*[NotMapped] public Dictionary PatientRecipes { get @@ -43,11 +49,9 @@ namespace HospitalDatabaseImplement.Models } return _patientRecipes; } - } - - [ForeignKey("PatientId")] - public virtual List Recipes { get; set; } = new(); + }*/ + private Dictionary? _patientProcedures = null; [NotMapped] @@ -63,9 +67,7 @@ namespace HospitalDatabaseImplement.Models } } - [ForeignKey("PatientId")] - public virtual List Procedures { get; set; } = new(); - + public static Patient Create(HospitalDatabase context, PatientBindingModel model) { return new Patient() @@ -77,10 +79,6 @@ namespace HospitalDatabaseImplement.Models BirthDate = model.BirthDate, DoctorId = model.DoctorId, Doctor = context.Doctors.First(x => x.Id == model.DoctorId), - Recipes = model.PatientRecipes.Select(x => new PatientRecipe - { - Recipe = context.Recipes.First(y => y.Id == x.Key), - }).ToList(), Procedures = model.PatientProcedures.Select(x => new PatientProcedure { Procedure = context.Procedures.First(y => y.Id == x.Key), @@ -93,36 +91,44 @@ namespace HospitalDatabaseImplement.Models FIO = model.FIO; Address = model.Address; BirthDate = model.BirthDate; - } + + + } public PatientViewModel GetViewModel => new() { FIO = FIO, Address = Address, BirthDate = BirthDate, - PatientRecipes = PatientRecipes, + PatientProcedures = PatientProcedures }; - public void UpdateRecipes(HospitalDatabase context, PatientBindingModel model) - { - var patientRecipes = context.PatientRecipes.Where(rec => rec.PatientId == model.Id).ToList(); - if (patientRecipes != null) - { // удалили те, которых нет в модели - context.PatientRecipes.RemoveRange(patientRecipes.Where(rec => !model.PatientRecipes.ContainsKey(rec.RecipeId))); - context.SaveChanges(); - } - var patient = context.Patients.First(x => x.Id == Id); - foreach (var pr in model.PatientRecipes) - { - context.PatientRecipes.Add(new PatientRecipe - { - Patient = patient, - Recipe = context.Recipes.First(x => x.Id == pr.Key), - }); - context.SaveChanges(); - } - _patientRecipes = null; - } - } + public void UpdateProcedures(HospitalDatabase context, PatientBindingModel model) + { + var servicePatients = context.PatientProcedures.Where(rec => rec.PatientId == model.Id).ToList(); + if (servicePatients != null) + { // удалили те, которых нет в модели + context.PatientProcedures.RemoveRange(servicePatients.Where(rec => !model.PatientProcedures.ContainsKey(rec.ProcedureId))); + context.SaveChanges(); + foreach (var service in servicePatients) + { + model.PatientProcedures.Remove(service.ProcedureId); + } + context.SaveChanges(); + } + var visit = context.Patients.First(x => x.Id == Id); + foreach (var pc in model.PatientProcedures) + { + context.PatientProcedures.Add(new PatientProcedure + { + Patient = visit, + Procedure = context.Procedures.First(x => x.Id == pc.Key), + + }); + context.SaveChanges(); + } + _patientProcedures = null; + } + } } diff --git a/Hospital/HospitalDatabaseImplement/Models/Procedure.cs b/Hospital/HospitalDatabaseImplement/Models/Procedure.cs index 67068bc..288b816 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Procedure.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Procedure.cs @@ -13,7 +13,7 @@ using HospitalDatabaseImplement.Modelss; namespace HospitalDatabaseImplement.Models { - // TODO переделать под все необходимые атрибуты фармацевту + public class Procedure : IProcedureModel { public int Id { get; set; } diff --git a/Hospital/HospitalDatabaseImplement/Models/Recipe.cs b/Hospital/HospitalDatabaseImplement/Models/Recipe.cs index aa1d074..5a564d8 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Recipe.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Recipe.cs @@ -30,23 +30,23 @@ namespace HospitalDatabaseImplement.Modelss [Required] public string Description { get; private set; } = string.Empty; - private Dictionary? _recipeMedicines = null; + private Dictionary? _recipePatients = null; [NotMapped] - public Dictionary RecipeMedicines + public Dictionary RecipePatients { get { - if (_recipeMedicines == null) + if (_recipePatients == null) { - _recipeMedicines = Medicines.ToDictionary(recRM => recRM.MedicineId, recRM => (recRM.Medicine as IMedicineModel)); + _recipePatients = Patients.ToDictionary(recRM => recRM.PatientId, recRM => (recRM.Patient as IPatientModel)); } - return _recipeMedicines; + return _recipePatients; } } [ForeignKey("RecipeId")] - public virtual List Medicines { get; set; } = new(); + public virtual List Patients { get; set; } = new(); public static Recipe Create(HospitalDatabase context, RecipeBindingModel model) { @@ -58,9 +58,9 @@ namespace HospitalDatabaseImplement.Modelss DiseaseId = model.DiseaseId, DoctorId = model.DoctorId, Doctor = context.Doctors.First(x => x.Id == model.DoctorId), - Medicines = model.RecipeMedicines.Select(x => new RecipeMedicine - { - Medicine = context.Medicines.First(y => y.Id == x.Key), + Patients = model.RecipePatients.Select(x => new PatientRecipe + { + Patient = context.Patients.First(y => y.Id == x.Key), }).ToList() }; } @@ -75,28 +75,28 @@ namespace HospitalDatabaseImplement.Modelss { Id = Id, IssueDate = IssueDate, - RecipeMedicines = RecipeMedicines + RecipePatients = RecipePatients }; - public void UpdateMedicines(HospitalDatabase context, RecipeBindingModel model) + public void UpdatePatients(HospitalDatabase context, RecipeBindingModel model) { - var recipeMedicines = context.RecipeMedicines.Where(rec => rec.RecipeId == model.Id).ToList(); - if (recipeMedicines != null) + var recipePatients = context.PatientRecipes.Where(rec => rec.RecipeId == model.Id).ToList(); + if (recipePatients != null) { // удалили те, которых нет в модели - context.RecipeMedicines.RemoveRange(recipeMedicines.Where(rec => !model.RecipeMedicines.ContainsKey(rec.MedicineId))); + context.PatientRecipes.RemoveRange(recipePatients.Where(rec => !model.RecipePatients.ContainsKey(rec.PatientId))); context.SaveChanges(); } var recipe = context.Recipes.First(x => x.Id == Id); - foreach (var pr in model.RecipeMedicines) + foreach (var pr in model.RecipePatients) { - context.RecipeMedicines.Add(new RecipeMedicine - { + context.PatientRecipes.Add(new PatientRecipe + { Recipe = recipe, - Medicine = context.Medicines.First(x => x.Id == pr.Key), + Patient = context.Patients.First(x => x.Id == pr.Key), }); context.SaveChanges(); } - _recipeMedicines = null; + _recipePatients = null; } } } diff --git a/Hospital/HospitalDoctorApp/Controllers/HomeController.cs b/Hospital/HospitalDoctorApp/Controllers/HomeController.cs index dc1e288..615c626 100644 --- a/Hospital/HospitalDoctorApp/Controllers/HomeController.cs +++ b/Hospital/HospitalDoctorApp/Controllers/HomeController.cs @@ -1,4 +1,5 @@ using HospitalContracts.BindingModels; +using HospitalContracts.ViewModels; using HospitalDoctorApp.Models; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; @@ -14,15 +15,55 @@ namespace HospitalDoctorApp.Controllers _logger = logger; } + + + [HttpGet] + public IActionResult CreatePatient() + { + return View(); + } + [HttpGet] + public IActionResult CreateDisease() + { + return View(); + } + [HttpGet] + public IActionResult CreateRecipe() + { + return View(); + } + public IActionResult Index() { - return View(); + if (APIClient.Doctor == null) + { + return Redirect("~/Home/Enter"); + } + return +View(APIClient.GetRequest>($"api/visit/getpatients?doctorId={APIClient.Doctor.Id}")); + + } + public IActionResult IndexRecipes() + { + if (APIClient.Doctor == null) + { + return Redirect("~/Home/Enter"); + } + return +View(APIClient.GetRequest>($"api/animal/getrecipelist?doctorId={APIClient.Doctor.Id}")); + + } + public IActionResult IndexDiseases() + { + if (APIClient.Doctor == null) + { + return Redirect("~/Home/Enter"); + } + return +View(APIClient.GetRequest>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}")); + } - public IActionResult Privacy() - { - return View(); - } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() @@ -31,14 +72,59 @@ namespace HospitalDoctorApp.Controllers } - // ВХОД И РЕГИСТРАЦИЯ // - + #region Вход и регистрация [HttpGet] public IActionResult Register() { return View(); } + + [HttpGet] + public IActionResult Privacy() + { + if (APIClient.Doctor == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.Doctor); + } + + [HttpGet] + public IActionResult Enter() + { + + return View(); + } + + [HttpPost] + public void Privacy(string login, string email, string password, string fio, string telephone) + { + if (APIClient.Doctor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIClient.PostRequest("api/doctor/updatedata", new DoctorBindingModel + { + Id = APIClient.Doctor.Id, + FIO = fio, + Login = login, + Password = password, + MailAddress = email, + PhoneNumber = telephone + }); + + APIClient.Doctor.FIO = fio; + APIClient.Doctor.Login = login; + APIClient.Doctor.Password = password; + APIClient.Doctor.MailAddress = email; + APIClient.Doctor.PhoneNumber = telephone; + Response.Redirect("Index"); + } [HttpPost] public void Register(string login, string email, string password, string fio, string telephone) @@ -59,5 +145,21 @@ namespace HospitalDoctorApp.Controllers Response.Redirect("Enter"); return; } + + [HttpPost] + public void Enter(string login, string password) + { + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите логин и пароль"); + } + APIClient.Doctor = APIClient.GetRequest($"api/doctor/login?login={login}&password={password}"); + if (APIClient.Doctor == null) + { + throw new Exception("Неверный логин/пароль"); + } + Response.Redirect("Index"); + } + #endregion } } diff --git a/Hospital/HospitalDoctorApp/Program.cs b/Hospital/HospitalDoctorApp/Program.cs index 0727468..868e558 100644 --- a/Hospital/HospitalDoctorApp/Program.cs +++ b/Hospital/HospitalDoctorApp/Program.cs @@ -1,9 +1,11 @@ +using HospitalDoctorApp; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); var app = builder.Build(); +APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) diff --git a/Hospital/HospitalDoctorApp/Views/Home/AddProcedureToPatient.cshtml b/Hospital/HospitalDoctorApp/Views/Home/AddProcedureToPatient.cshtml new file mode 100644 index 0000000..384b77e --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/AddProcedureToPatient.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "CreateDisease"; +} + + + + + +
+
+ + +
+ +
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/CreateDisease.cshtml b/Hospital/HospitalDoctorApp/Views/Home/CreateDisease.cshtml new file mode 100644 index 0000000..384b77e --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/CreateDisease.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "CreateDisease"; +} + + + + + +
+
+ + +
+ +
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/CreatePatient.cshtml b/Hospital/HospitalDoctorApp/Views/Home/CreatePatient.cshtml index 7e36b26..ba379f3 100644 --- a/Hospital/HospitalDoctorApp/Views/Home/CreatePatient.cshtml +++ b/Hospital/HospitalDoctorApp/Views/Home/CreatePatient.cshtml @@ -8,17 +8,24 @@
- +
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/CreateRecipe.cshtml b/Hospital/HospitalDoctorApp/Views/Home/CreateRecipe.cshtml new file mode 100644 index 0000000..7da6825 --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/CreateRecipe.cshtml @@ -0,0 +1,51 @@ +@{ + ViewData["Title"] = "CreateRecipe"; +} + +
+

Создание рецепта

+
+ +
+
Описание:
+
+ +
+
+
+
Болезнь:
+
+ +
+
+
+
Дата назначения:
+
+ +
+
+
+
+
+ +
+
+ + + diff --git a/Hospital/HospitalDoctorApp/Views/Home/DeleteDisease.cshtml b/Hospital/HospitalDoctorApp/Views/Home/DeleteDisease.cshtml new file mode 100644 index 0000000..384b77e --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/DeleteDisease.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "CreateDisease"; +} + + + + + +
+
+ + +
+ +
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/DeletePatient.cshtml b/Hospital/HospitalDoctorApp/Views/Home/DeletePatient.cshtml new file mode 100644 index 0000000..384b77e --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/DeletePatient.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "CreateDisease"; +} + + + + + +
+
+ + +
+ +
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/DeleteRecipe.cshtml b/Hospital/HospitalDoctorApp/Views/Home/DeleteRecipe.cshtml new file mode 100644 index 0000000..384b77e --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/DeleteRecipe.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "CreateDisease"; +} + + + + + +
+
+ + +
+ +
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/Index.cshtml b/Hospital/HospitalDoctorApp/Views/Home/Index.cshtml index 204fb56..e1f741e 100644 --- a/Hospital/HospitalDoctorApp/Views/Home/Index.cshtml +++ b/Hospital/HospitalDoctorApp/Views/Home/Index.cshtml @@ -1,12 +1,63 @@ -@{ - ViewData["Title"] = "Home Page"; +@using HospitalContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "Home Page"; }
-

Welcome

-

Learn about building Web apps with ASP.NET Core.

- Добавить - Пациенты - +

Пациенты

+
+ +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } +

+ Редактировать пациента + Удалить пациента + Связать пацииента и процедуру +

+

+ Создать пациента +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
+ Номер + + Название + + Дата +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.FIO) + + @Html.DisplayFor(modelItem => item.Address) +
+ }
diff --git a/Hospital/HospitalDoctorApp/Views/Home/IndexDiseases.cshtml b/Hospital/HospitalDoctorApp/Views/Home/IndexDiseases.cshtml new file mode 100644 index 0000000..093da75 --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/IndexDiseases.cshtml @@ -0,0 +1,62 @@ +@using HospitalContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "IndexDiseases"; +} + +
+

Болезни

+
+ +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } +

+ Редактировать болезнь + Удалить болезнь +

+

+ Создать болезнь +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
+ Номер + + Название + + Описание +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.Name) + + @Html.DisplayFor(modelItem => item.Description) +
+ } +
diff --git a/Hospital/HospitalDoctorApp/Views/Home/IndexRecipes.cshtml b/Hospital/HospitalDoctorApp/Views/Home/IndexRecipes.cshtml new file mode 100644 index 0000000..ab01bce --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/IndexRecipes.cshtml @@ -0,0 +1,63 @@ +@using HospitalContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "IndexRecipe"; +} + +
+

Рецепты

+
+ +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } +

+ Редактировать рецепт + Удалить рецепт + Связать рецепт и пациента +

+

+ Создать рецепт +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
+ Номер + + Описание + + Дата +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.Description) + + @Html.DisplayFor(modelItem => item.IssueDate) +
+ } +
\ No newline at end of file diff --git a/Hospital/HospitalDoctorApp/Views/Home/LinkPatientAndProcedure.cshtml b/Hospital/HospitalDoctorApp/Views/Home/LinkPatientAndProcedure.cshtml new file mode 100644 index 0000000..384b77e --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/LinkPatientAndProcedure.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "CreateDisease"; +} + + + + + +
+
+ + +
+ +
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/Privacy.cshtml b/Hospital/HospitalDoctorApp/Views/Home/Privacy.cshtml index af4fb19..5857762 100644 --- a/Hospital/HospitalDoctorApp/Views/Home/Privacy.cshtml +++ b/Hospital/HospitalDoctorApp/Views/Home/Privacy.cshtml @@ -1,6 +1,60 @@ -@{ - ViewData["Title"] = "Privacy Policy"; -} -

@ViewData["Title"]

+@using HospitalContracts.ViewModels -

Use this page to detail your site's privacy policy.

+@model DoctorViewModel + +@{ + ViewData["Title"] = "Privacy"; +} + + + +
+

Мои данные

+
+
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/UpdateDisease.cshtml b/Hospital/HospitalDoctorApp/Views/Home/UpdateDisease.cshtml new file mode 100644 index 0000000..384b77e --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/UpdateDisease.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "CreateDisease"; +} + + + + + +
+
+ + +
+ +
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/UpdatePatient.cshtml b/Hospital/HospitalDoctorApp/Views/Home/UpdatePatient.cshtml new file mode 100644 index 0000000..384b77e --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/UpdatePatient.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "CreateDisease"; +} + + + + + +
+
+ + +
+ +
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/UpdateRecipe.cshtml b/Hospital/HospitalDoctorApp/Views/Home/UpdateRecipe.cshtml new file mode 100644 index 0000000..384b77e --- /dev/null +++ b/Hospital/HospitalDoctorApp/Views/Home/UpdateRecipe.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "CreateDisease"; +} + + + + + +
+
+ + +
+ +
+
+
+
+
diff --git a/Hospital/HospitalDoctorApp/appsettings.json b/Hospital/HospitalDoctorApp/appsettings.json index b50157c..a1c4530 100644 --- a/Hospital/HospitalDoctorApp/appsettings.json +++ b/Hospital/HospitalDoctorApp/appsettings.json @@ -6,5 +6,5 @@ } }, "AllowedHosts": "*", - //TODO "IPAddress": "http://localhost:5159/" + "IPAddress": "http://localhost:5092/" } diff --git a/Hospital/HospitalRestApi/Controllers/DoctorController.cs b/Hospital/HospitalRestApi/Controllers/DoctorController.cs new file mode 100644 index 0000000..13588a1 --- /dev/null +++ b/Hospital/HospitalRestApi/Controllers/DoctorController.cs @@ -0,0 +1,67 @@ +using HospitalContracts.BindingModels; +using HospitalContracts.BusinessLogicContracts; +using HospitalContracts.SearchModels; +using HospitalContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace HospitalRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class DoctorController : Controller + { + private readonly ILogger _logger; + private readonly IDoctorLogic _logic; + public DoctorController(IDoctorLogic logic, ILogger logger) + { + _logger = logger; + _logic = logic; + } + + [HttpGet] + public DoctorViewModel? Login(string login, string password) + { + try + { + return _logic.ReadElement(new DoctorSearchModel + { + Login = login, + Password = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + [HttpPost] + public void Register(DoctorBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка регистрации"); + throw; + } + } + + [HttpPost] + public void UpdateData(DoctorBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления данных"); + throw; + } + } + } +} \ No newline at end of file diff --git a/Hospital/HospitalRestApi/Controllers/MedicineController.cs b/Hospital/HospitalRestApi/Controllers/MedicineController.cs index 6f49b64..f5d6316 100644 --- a/Hospital/HospitalRestApi/Controllers/MedicineController.cs +++ b/Hospital/HospitalRestApi/Controllers/MedicineController.cs @@ -22,7 +22,7 @@ namespace HospitalRestApi.Controllers _medicine = medicine; } - [HttpGet] + /*[HttpGet] public Tuple>? GetMedicine(int medicineId) { try @@ -88,7 +88,7 @@ namespace HospitalRestApi.Controllers _logger.LogError(ex, "Не удалось обновить магазин"); throw; } - } + }*/ [HttpPost] public bool DeleteMedicine(MedicineBindingModel model) diff --git a/Hospital/HospitalRestApi/Controllers/WeatherForecastController.cs b/Hospital/HospitalRestApi/Controllers/WeatherForecastController.cs deleted file mode 100644 index d68e80c..0000000 --- a/Hospital/HospitalRestApi/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace HospitalRestApi.Controllers -{ - [ApiController] - [Route("[controller]")] - public class WeatherForecastController : ControllerBase - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateTime.Now.AddDays(index), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} \ No newline at end of file diff --git a/Hospital/HospitalRestApi/HospitalRestApi.csproj b/Hospital/HospitalRestApi/HospitalRestApi.csproj index a2bafdc..c04c4b5 100644 --- a/Hospital/HospitalRestApi/HospitalRestApi.csproj +++ b/Hospital/HospitalRestApi/HospitalRestApi.csproj @@ -7,6 +7,7 @@ + diff --git a/Hospital/HospitalRestApi/Program.cs b/Hospital/HospitalRestApi/Program.cs index 48863a6..28a2ff0 100644 --- a/Hospital/HospitalRestApi/Program.cs +++ b/Hospital/HospitalRestApi/Program.cs @@ -1,21 +1,58 @@ +using HospitalBusinessLogic.BusinessLogics; +using HospitalContracts.BusinessLogicContracts; +using HospitalContracts.StoragesContracts; +using HospitalDatabaseImplement.Implements; +using HospitalDatabaseImplement.Implementss; +using Microsoft.OpenApi.Models; + var builder = WebApplication.CreateBuilder(args); +builder.Logging.SetMinimumLevel(LogLevel.Trace); +builder.Logging.AddLog4Net("log4net.config"); + // Add services to the container. +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); - +builder.Services.AddSwaggerGen(c => +{ + c.SwaggerDoc("v1", new OpenApiInfo + { + Title = "HospitalRestApi", + Version + = "v1" + }); +}); var app = builder.Build(); - // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); - app.UseSwaggerUI(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", + "HospitalRestApi v1")); } + app.UseHttpsRedirection(); app.UseAuthorization(); diff --git a/Hospital/HospitalRestApi/WeatherForecast.cs b/Hospital/HospitalRestApi/WeatherForecast.cs deleted file mode 100644 index 49438f4..0000000 --- a/Hospital/HospitalRestApi/WeatherForecast.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace HospitalRestApi -{ - public class WeatherForecast - { - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } - } -} \ No newline at end of file diff --git a/Hospital/HospitalRestApi/log4net.config b/Hospital/HospitalRestApi/log4net.config new file mode 100644 index 0000000..58cf721 --- /dev/null +++ b/Hospital/HospitalRestApi/log4net.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file