mission complete

This commit is contained in:
Alenka 2024-05-03 15:20:53 +04:00
parent 993cd30fde
commit 49aa246bcf
10 changed files with 25 additions and 24 deletions

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using HospitalBusinessLogic.OfficePackage;
namespace VetClinicBusinessLogic.OfficePackage.Implements
{

View File

@ -11,7 +11,7 @@ namespace HospitalContracts.BusinessLogicsContracts
{
public interface IReportLogicPharmacist //В процессе
{
List<ListRecipesViewModel> GetProcedureRecipes(List<int> services);
List<ListRecipesViewModel> GetProcedureRecipes(List<int> procedures);
void SaveRecipesToWordFile(ListRecipesBindingModel model);
void SaveRecipesToExcelFile(ListRecipesBindingModel model);
}

View File

@ -45,9 +45,9 @@ namespace HospitalDatabaseImplement.Implements
return context.Medicines
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>>>(medicine.GetViewModel,
context.ProcedureMedicines.Include(service => service.Procedure)
.Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId).
Select(service => new Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>(service.Procedure.GetViewModel,
context.ProcedureMedicines.Include(procedure => procedure.Procedure)
.Include(procedure => procedure.Medicine).Where(procedure => medicine.Id == procedure.MedicineId).
Select(procedure => new Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>(procedure.Procedure.GetViewModel,
context.DescriptionProcedures.Include(x => x.Procedures).
Select(x => x.GetViewModel).ToList())).ToList())).ToList();
@ -62,10 +62,10 @@ namespace HospitalDatabaseImplement.Implements
return context.Medicines
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<PatientViewModel>>>>(medicine.GetViewModel,
context.ProcedureMedicines.Include(service => service.Procedure)
.Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId).
Select(service => new Tuple<ProcedureViewModel, List<PatientViewModel>>(service.Procedure.GetViewModel,
context.PatientProcedures.Include(x => x.Patient).Where(x => x.ProcedureId == service.ProcedureId ).
context.ProcedureMedicines.Include(procedure => procedure.Procedure)
.Include(procedure => procedure.Medicine).Where(procedure => medicine.Id == procedure.MedicineId).
Select(procedure => new Tuple<ProcedureViewModel, List<PatientViewModel>>(procedure.Procedure.GetViewModel,
context.PatientProcedures.Include(x => x.Patient).Where(x => x.ProcedureId == procedure.ProcedureId ).
Select(x => x.Patient.GetViewModel).ToList())).ToList())).ToList();
}

View File

@ -468,7 +468,7 @@ namespace HospitalDatabaseImplement.Migrations
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
.WithMany("Services")
.WithMany("procedures")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -545,7 +545,7 @@ namespace HospitalDatabaseImplement.Migrations
{
b.Navigation("Recipes");
b.Navigation("Services");
b.Navigation("procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>

View File

@ -465,7 +465,7 @@ namespace HospitalDatabaseImplement.Migrations
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
.WithMany("Services")
.WithMany("procedures")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -542,7 +542,7 @@ namespace HospitalDatabaseImplement.Migrations
{
b.Navigation("Recipes");
b.Navigation("Services");
b.Navigation("procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>

View File

@ -106,14 +106,14 @@ namespace HospitalDatabaseImplement.Models
public void UpdateProcedures(HospitalDatabase context, PatientBindingModel model)
{
var servicePatients = context.PatientProcedures.Where(rec => rec.PatientId == model.Id).ToList();
if (servicePatients != null)
var procedurePatients = context.PatientProcedures.Where(rec => rec.PatientId == model.Id).ToList();
if (procedurePatients != null)
{ // удалили те, которых нет в модели
context.PatientProcedures.RemoveRange(servicePatients.Where(rec => !model.PatientProcedures.ContainsKey(rec.ProcedureId)));
context.PatientProcedures.RemoveRange(procedurePatients.Where(rec => !model.PatientProcedures.ContainsKey(rec.ProcedureId)));
context.SaveChanges();
foreach (var service in servicePatients)
foreach (var procedure in procedurePatients)
{
model.PatientProcedures.Remove(service.ProcedureId);
model.PatientProcedures.Remove(procedure.ProcedureId);
}
context.SaveChanges();
}

View File

@ -1,7 +1,7 @@
using HospitalDoctorApp;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Add procedures to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();

View File

@ -94,7 +94,7 @@ View(APIPharmacist.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?
[HttpGet]
public IActionResult RecipeListReport()
{
ViewBag.Services = APIPharmacist.GetRequest<List<RecipeViewModel>>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}");
ViewBag.procedures = APIPharmacist.GetRequest<List<RecipeViewModel>>($"api/procedure/getprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}");
return View();
}
[HttpGet]

View File

@ -20,10 +20,10 @@
<p>
<a asp-action="UpdatePatient">Редактировать лекарство</a>
<a asp-action="DeletePatient">Удалить лекарство</a>
<a asp-action="ServiceVisits">Связать лекарство и рецепт</a>
<a asp-action="ProcedurePatients">Связать лекарство и рецепт</a>
</p>
<p>
<a asp-action="CreatePatient">Создать лекарство</a>
<a asp-action="CreateMedicine">Создать лекарство</a>
</p>
<table class="table">
<thead>

View File

@ -14,9 +14,9 @@
return;
}
<p>
<a asp-action="CreateService">Создать процедуру</a>
<a asp-action="UpdateService">Обновить процедуру</a>
<a asp-action="DeleteService">Удалить процедуру</a>
<a asp-action="Createprocedure">Создать процедуру</a>
<a asp-action="Updateprocedure">Обновить процедуру</a>
<a asp-action="Deleteprocedure">Удалить процедуру</a>
</p>
<table class="table">
<thead>