From 09d9cebef13f23b277c9f922aefb1a24c3665ad8 Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Sun, 26 May 2024 11:53:10 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=81=D1=91,=20=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VeterinaryContracts/ViewModels/ServiceViewModel.cs | 2 ++ .../VeterinaryDatabaseImplement/Implements/DrugStorage.cs | 5 +++-- VeterinaryView/VeterinaryDatabaseImplement/Models/Drug.cs | 7 ++++--- .../VeterinaryDatabaseImplement/Models/Service.cs | 2 ++ VeterinaryView/VeterinaryRestApi/Program.cs | 8 ++++++++ .../VeterinaryShowDoctorApp/Controllers/HomeController.cs | 3 +-- .../VeterinaryShowDoctorApp/Views/Home/Services.cshtml | 2 +- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/ServiceViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/ServiceViewModel.cs index 3046ceb..f3f2f8b 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/ServiceViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/ServiceViewModel.cs @@ -15,6 +15,8 @@ namespace VeterinaryContracts.ViewModels public string ServiceName { get; set; } = string.Empty; public int VisitId { get; set; } public int DoctorId { get; set; } + [DisplayName("Посещение")] + public string VisitName { get; set; } = string.Empty; public Dictionary ServiceMedications { get; diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Implements/DrugStorage.cs b/VeterinaryView/VeterinaryDatabaseImplement/Implements/DrugStorage.cs index 66df2f4..e4270ed 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Implements/DrugStorage.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Implements/DrugStorage.cs @@ -79,9 +79,10 @@ namespace VeterinaryDatabaseImplement.Implements return null; } - drug.UpdateMedications(context, model); + drug.UpdateMedications(context, model); // работает + context.SaveChanges(); + drug.Update(context,model);// не работает сумма context.SaveChanges(); - drug.Update(context,model); transaction.Commit(); return drug.GetViewModel; } diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Drug.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Drug.cs index 9ca3629..569d37c 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Drug.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Drug.cs @@ -68,19 +68,20 @@ namespace VeterinaryDatabaseImplement.Models DateCreate= model.DateCreate }; } + // цену считает неверно public void Update(VeterinaryDatabase context, DrugBindingModel model) { var justMedications = model.DrugMedications.Select(x => new DrugMedication { Medication = context.Medications.First(y => y.Id == x.Key) }).ToList(); - double prc = 0; + double pric = 0; foreach (var justMedication in justMedications) { - prc += justMedication.Medication.Price; + pric += justMedication.Medication.Price; } DrugName = model.DrugName; - Price = prc; + Price = pric; } public DrugViewModel GetViewModel => new() { diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Service.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Service.cs index 494c3d9..3d5558e 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Service.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Service.cs @@ -65,6 +65,8 @@ namespace VeterinaryDatabaseImplement.Models ServiceName = ServiceName, DoctorId = DoctorId, VisitId = VisitId, + VisitName = Visit?.VisitName ?? string.Empty, + }; public void UpdateMedications(VeterinaryDatabase context, ServiceBindingModel model) diff --git a/VeterinaryView/VeterinaryRestApi/Program.cs b/VeterinaryView/VeterinaryRestApi/Program.cs index 48b2afc..895efe2 100644 --- a/VeterinaryView/VeterinaryRestApi/Program.cs +++ b/VeterinaryView/VeterinaryRestApi/Program.cs @@ -5,6 +5,9 @@ using VeterinaryContracts.StorageContracts; using VeterinaryDatabaseImplement.Implements; using Microsoft.OpenApi.Models; using VeterinaryBusinessLogic.MailWorker; +using VeterinaryBusinessLogic.OfficePackage; +using VeterinaryBusinessLogic.OfficePackage.Implements; + var builder = WebApplication.CreateBuilder(args); @@ -27,6 +30,11 @@ 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.AddSingleton(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs b/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs index dce67d2..2b028d7 100644 --- a/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs +++ b/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs @@ -293,7 +293,6 @@ namespace VeterinaryShowDoctorApp.Controllers { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } - double _price=0; if (string.IsNullOrEmpty(name) || count <= 0) { throw new Exception("Ошибка в введенных данных"); @@ -405,7 +404,7 @@ namespace VeterinaryShowDoctorApp.Controllers return Redirect("~/Home/Enter"); } ViewBag.Services = APIDoctor.GetRequest>($"api/service/getservices?doctorid={APIDoctor.Doctor.Id}"); - ViewBag.Medications = APIDoctor.GetRequest>($"api/medication/getmedications"); + ViewBag.Medications = APIDoctor.GetRequest>($"api/medication/getmedications?doctorid={APIDoctor.Doctor.Id}"); return View(); } // возможно нужно прописать визит айди diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/Services.cshtml b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/Services.cshtml index f41a70a..174f3d8 100644 --- a/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/Services.cshtml +++ b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/Services.cshtml @@ -43,7 +43,7 @@ @Html.DisplayFor(modelItem =>item.ServiceName) - @Html.DisplayFor(modelItem =>item.VisitId) + @Html.DisplayFor(modelItem =>item.VisitName) }