продолжение изменнеий моделей, бд и приложений и контроллеров

This commit is contained in:
ValAnn 2024-04-30 16:16:49 +04:00
parent 52f5e5a1e3
commit cf75520b70
58 changed files with 1057 additions and 280 deletions

View File

@ -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)
{

View File

@ -26,7 +26,7 @@ namespace HospitalBusinessLogic.BusinessLogics
}
public List<PharmacistViewModel>? 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
{

View File

@ -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
{

View File

@ -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; }
}
}

View File

@ -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<int, IRecipeModel> MedicineRecipes { get; set; } = new();
}
}

View File

@ -21,6 +21,5 @@ namespace HospitalContracts.BindingModels
public Dictionary<int, IProcedureModel> PatientProcedures { get; set; } = new();
public Dictionary<int, IRecipeModel> PatientRecipes { get; set; } = new();
}
}

View File

@ -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<int, IMedicineModel> ProcedureMedicines { get; set; } = new();
}
}
}
}

View File

@ -18,6 +18,6 @@ namespace HospitalContracts.BindingModels
public int DoctorId { get; set; }
public Dictionary<int, IMedicineModel> RecipeMedicines { get; set; } = new();
public Dictionary<int, IPatientModel> RecipePatients { get; set; } = new();
}
}

View File

@ -11,5 +11,6 @@ namespace HospitalContracts.SearchModels
public int? Id { get; set; }
public int? DoctorId { get; set; }
}
DateTime IssueDate { get; }
}
}

View File

@ -16,5 +16,7 @@ namespace HospitalContracts.ViewModels
[DisplayName("Фармацевт")]
public int PharmacistId { get; set; }
}
}
}

View File

@ -20,6 +20,8 @@ namespace HospitalContracts.ViewModels
[DisplayName("Фармацевт")]
public int PharmacistId { get; set; }
}
public Dictionary<int, IRecipeModel> MedicineRecipes { get; set; } = new();
}
}

View File

@ -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<int, IProcedureModel> PatientProcedures { get; set; } = new();
public Dictionary<int, IRecipeModel> PatientRecipes { get; set; } = new();
}
}

View File

@ -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; }

View File

@ -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<int, IMedicineModel> RecipeMedicines { get; set; } = new();
public Dictionary<int, IPatientModel> RecipePatients { get; set; } = new();
public int Id { get; set; }
}
}

View File

@ -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)

View File

@ -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;

View File

@ -28,7 +28,7 @@ namespace HospitalDatabaseImplement.Models
[ForeignKey("IDescriptionProcedureId")]
public virtual List<Procedure> 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
};
}
}

View File

@ -7,10 +7,10 @@ using System.Threading.Tasks;
namespace HospitalDataModels.Models
{
public interface IDescriptionProcedureModel
public interface IDescriptionProcedureModel : IId
{
string Description { get; }
int PharmacistId { get; }
}
}
}

View File

@ -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; }
}
}

View File

@ -12,6 +12,7 @@ namespace HospitalDataModels.Models
string CountryOrigin { get; }
double Price { get; }
int PharmacistId { get; }
}
Dictionary<int, IRecipeModel> MedicineRecipes { get; }
}
}

View File

@ -14,6 +14,5 @@ namespace HospitalDataModels.Models
int DoctorId { get; }
Dictionary<int, IProcedureModel> PatientProcedures { get; }
Dictionary<int, IRecipeModel> PatientRecipes { get; }
}
}

View File

@ -16,6 +16,6 @@ namespace HospitalDataModels.Models
int DoctorId { get; }
Dictionary<int, IMedicineModel> RecipeMedicines { get; }
Dictionary<int, IPatientModel> RecipePatients { get; }
}
}

View File

@ -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<DoctorViewModel> GetFilteredList(DoctorSearchModel model)
{

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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
{
/// <inheritdoc />
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
}

View File

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace HospitalDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class InitCreate : Migration
{
/// <inheritdoc />
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<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
DescriptionProcedureId = table.Column<int>(type: "int", nullable: false),
IDescriptionProcedureId = table.Column<int>(type: "int", nullable: false),
PharmacistId = table.Column<int>(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(

View File

@ -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
}

View File

@ -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,

View File

@ -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<RecipeMedicine> RecipeMedicines { get; set; } = new();
private Dictionary<int, IRecipeModel>? _medicineRecipes =
null;
[NotMapped]
public Dictionary<int, IRecipeModel> 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<RecipeMedicine> Recipes { get; set; } = new();
[ForeignKey("MedicineId")]
public virtual List<ProcedureMedicine> 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;
}
}
}

View File

@ -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<int, IRecipeModel>? _patientRecipes = null;
[NotMapped]
[ForeignKey("PatientId")]
public virtual List<PatientProcedure> Procedures { get; set; } = new();
[ForeignKey("PatientId")]
public virtual List<PatientRecipe> Recipes { get; set; } = new();
/*[NotMapped]
public Dictionary<int, IRecipeModel> PatientRecipes
{
get
@ -43,11 +49,9 @@ namespace HospitalDatabaseImplement.Models
}
return _patientRecipes;
}
}
[ForeignKey("PatientId")]
public virtual List<PatientRecipe> Recipes { get; set; } = new();
}*/
private Dictionary<int, IProcedureModel>? _patientProcedures = null;
[NotMapped]
@ -63,9 +67,7 @@ namespace HospitalDatabaseImplement.Models
}
}
[ForeignKey("PatientId")]
public virtual List<PatientProcedure> 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;
}
}
}

View File

@ -13,7 +13,7 @@ using HospitalDatabaseImplement.Modelss;
namespace HospitalDatabaseImplement.Models
{
// TODO переделать под все необходимые атрибуты фармацевту
public class Procedure : IProcedureModel
{
public int Id { get; set; }

View File

@ -30,23 +30,23 @@ namespace HospitalDatabaseImplement.Modelss
[Required]
public string Description { get; private set; } = string.Empty;
private Dictionary<int, IMedicineModel>? _recipeMedicines = null;
private Dictionary<int, IPatientModel>? _recipePatients = null;
[NotMapped]
public Dictionary<int, IMedicineModel> RecipeMedicines
public Dictionary<int, IPatientModel> 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<RecipeMedicine> Medicines { get; set; } = new();
public virtual List<PatientRecipe> 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;
}
}
}

View File

@ -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<List<PatientViewModel>>($"api/visit/getpatients?doctorId={APIClient.Doctor.Id}"));
}
public IActionResult IndexRecipes()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
return
View(APIClient.GetRequest<List<RecipeViewModel>>($"api/animal/getrecipelist?doctorId={APIClient.Doctor.Id}"));
}
public IActionResult IndexDiseases()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
return
View(APIClient.GetRequest<List<DiseaseViewModel>>($"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<DoctorViewModel>($"api/doctor/login?login={login}&password={password}");
if (APIClient.Doctor == null)
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
}
#endregion
}
}

View File

@ -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())

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -8,17 +8,24 @@
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">ФИО пациента</label>
<label class="u-label u-text-custom-color-1 u-label-1">ФИО участника</label>
<input type="text"
placeholder="Введите название конференции"
name="conferenceName"
placeholder="Введите ФИО"
name="fio"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="datetime-local"
placeholder="Выберите дату начала"
name="startDate"
<label class="u-label u-text-custom-color-1 u-label-2">Дата рождения</label>
<input type="date"
placeholder="Введите дату рождения"
name="birthdate"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Адрес</label>
<input type="text"
placeholder="Введите адрес "
name="address"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">

View File

@ -0,0 +1,51 @@
@{
ViewData["Title"] = "CreateRecipe";
}
<div class="text-center">
<h2 class="display-4">Создание рецепта</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8">
<input type="text" name="description" />
</div>
</div>
<div class="row">
<div class="col-4">Болезнь:</div>
<div class="col-8">
<select id="disease" name="disease" class="form-control" asp-items="@(new SelectList(@ViewBag.Diseases, "Id", "Name"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Дата назначения:</div>
<div class="col-8">
<input type="datetime" name="date" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
</form>
<script>
$('#disease').on('change', function () {
//check();
});
function check() {
if (snack) {
$.ajax({
method: "POST",
url: "/Home/GetDisease",
data: { disease: disease },
success: function (result) {
$("#disease").val(result);
}
});
};
}
</script>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -1,12 +1,63 @@
@{
ViewData["Title"] = "Home Page";
@using HospitalContracts.ViewModels
@model List<PatientViewModel>
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
<a asp-area="" asp-controller="Home" asp-action="CreatePatient"
class="u-active-custom-color-6 u-border-none u-btn u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1">Добавить</a>
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Пациенты</a>
<h1 class="display-4">Пациенты</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="Update">Редактировать пациента</a>
<a asp-action="Delete">Удалить пациента</a>
<a asp-action="ServiceVisits">Связать пацииента и процедуру</a>
</p>
<p>
<a asp-action="Create">Создать пациента</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название
</th>
<th>
Дата
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.FIO)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,62 @@
@using HospitalContracts.ViewModels
@model List<DiseaseViewModel>
@{
ViewData["Title"] = "IndexDiseases";
}
<div class="text-center">
<h1 class="display-4">Болезни</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="UpdateAnimal">Редактировать болезнь</a>
<a asp-action="DeleteAnimal">Удалить болезнь</a>
</p>
<p>
<a asp-action="CreateAnimal">Создать болезнь</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название
</th>
<th>
Описание
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,63 @@
@using HospitalContracts.ViewModels
@model List<RecipeViewModel>
@{
ViewData["Title"] = "IndexRecipe";
}
<div class="text-center">
<h1 class="display-4">Рецепты</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="Update">Редактировать рецепт</a>
<a asp-action="Delete">Удалить рецепт</a>
<a asp-action="ServiceVisits">Связать рецепт и пациента</a>
</p>
<p>
<a asp-action="Create">Создать рецепт</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Описание
</th>
<th>
Дата
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.IssueDate)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -1,6 +1,60 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
@using HospitalContracts.ViewModels
<p>Use this page to detail your site's privacy policy.</p>
@model DoctorViewModel
@{
ViewData["Title"] = "Privacy";
}
<head>
<link rel="stylesheet" href="~/css/register.css" asp-append-version="true" />
</head>
<div class="text-center">
<h2 class="u-text u-text-custom-color-1 u-text-default u-text-1"> Мои данные </h2>
</div>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Логин</label>
<input type="text"
placeholder="Введите логин"
name="login"
value="@Model.Login"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Электронная почта</label>
<input type="email"
placeholder="Введите электронную почту"
name="email"
value="@Model.MailAddress"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-group u-label-top u-form-group-3">
<label class="u-label u-text-custom-color-1 u-label-3">ФИО</label>
<input type="text"
placeholder="Введите ФИО"
name="fio"
value="@Model.FIO"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-group u-label-top u-form-group-4">
<label class="u-label u-text-custom-color-1 u-label-4">Номер телефона</label>
<input type="text"
name="telephone"
class="u-input u-input-rectangle"
value="@Model.PhoneNumber"
placeholder="Введите номер телефона" />
</div>
<div class="u-form-group u-label-top u-form-group-5">
<label class="u-label u-text-custom-color-1 u-label-5">Пароль</label>
<input type="text"
placeholder="Введите пароль"
name="password"
value="@Model.Password"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-center u-form-group u-form-submit u-label-top"
style="padding-bottom: 120px">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Изменить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -6,5 +6,5 @@
}
},
"AllowedHosts": "*",
//TODO "IPAddress": "http://localhost:5159/"
"IPAddress": "http://localhost:5092/"
}

View File

@ -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<DoctorController> 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;
}
}
}
}

View File

@ -22,7 +22,7 @@ namespace HospitalRestApi.Controllers
_medicine = medicine;
}
[HttpGet]
/*[HttpGet]
public Tuple<MedicineViewModel, List<string>>? GetMedicine(int medicineId)
{
try
@ -88,7 +88,7 @@ namespace HospitalRestApi.Controllers
_logger.LogError(ex, "Не удалось обновить магазин");
throw;
}
}
}*/
[HttpPost]
public bool DeleteMedicine(MedicineBindingModel model)

View File

@ -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<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> 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();
}
}
}

View File

@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>

View File

@ -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<IDoctorStorage, DoctorStorage>();
builder.Services.AddTransient<IDiseaseStorage, DiseaseStorage>();
builder.Services.AddTransient<IPatientStorage, PatientStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
builder.Services.AddTransient<IDoctorLogic, DoctorLogic>();
builder.Services.AddTransient<IDiseaseLogic, DiseaseLogic>();
builder.Services.AddTransient<IPatientLogic, PatientLogic>();
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
builder.Services.AddTransient<IPharmacistStorage, PharmacistStorage>();
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicineStorage, MedicineStorage>();
builder.Services.AddTransient<IDescriptionProcedureStorage, DescriptionProcedureStorage>();
builder.Services.AddTransient<IPharmacistLogic, PharmacistLogic>();
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
builder.Services.AddTransient<IMedicineLogic, MedicineLogic>();
builder.Services.AddTransient<IDescriptionProcedureLogic, DescriptionProcedureLogic>();
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();

View File

@ -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; }
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="c:/temp/HotelRestApi.log" />
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
</layout>
</appender>
<root>
<level value="TRACE" />
<appender-ref ref="RollingFile" />
</root>
</log4net>