From e4536d16c072e1dc6515a45247e656fdf0979003 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Mon, 13 May 2024 14:36:30 +0400 Subject: [PATCH] fix client app p.2 --- .../BusinessLogic/ServiceLogic.cs | 2 +- .../CarShowroomDataModels/AbstractModels/IService.cs | 2 +- CarShowroom/CarShowroomDataModels/Dtos/ServiceDto.cs | 4 ++-- CarShowroom/CarShowroomDataModels/Views/CarView.cs | 4 +--- CarShowroom/CarShowroomDataModels/Views/ServiceView.cs | 4 ++-- .../CarShowroomDatabaseStorage/CarShowroomDatabase.cs | 2 +- CarShowroom/CarShowroomDatabaseStorage/Entities/Car.cs | 3 +-- .../CarShowroomDatabaseStorage/Entities/Service.cs | 6 +++--- .../CarShowroomDatabaseStorage/Storages/CarStorage.cs | 7 ++++++- .../Controllers/HomeController.cs | 10 +++++----- .../Views/Home/ClientUpdate.cshtml | 9 ++++++++- .../CarShowroomManagerApp/Views/Home/SaleCreate.cshtml | 8 ++++---- CarShowroom/CarShowroomManagerApp/libman.json | 5 +++++ 13 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 CarShowroom/CarShowroomManagerApp/libman.json diff --git a/CarShowroom/CarShowroomBusinessLogic/BusinessLogic/ServiceLogic.cs b/CarShowroom/CarShowroomBusinessLogic/BusinessLogic/ServiceLogic.cs index 747018a..a74b305 100644 --- a/CarShowroom/CarShowroomBusinessLogic/BusinessLogic/ServiceLogic.cs +++ b/CarShowroom/CarShowroomBusinessLogic/BusinessLogic/ServiceLogic.cs @@ -82,7 +82,7 @@ namespace CarShowroomBusinessLogic.BusinessLogic return; if (string.IsNullOrEmpty(model.Name)) throw new InvalidOperationException(); - if (model.Cost < 0) + if (model.Price < 0) throw new InvalidOperationException(); var element = _serviceStorage.GetElement(new ServiceSearch { diff --git a/CarShowroom/CarShowroomDataModels/AbstractModels/IService.cs b/CarShowroom/CarShowroomDataModels/AbstractModels/IService.cs index 36dc180..6431664 100644 --- a/CarShowroom/CarShowroomDataModels/AbstractModels/IService.cs +++ b/CarShowroom/CarShowroomDataModels/AbstractModels/IService.cs @@ -10,6 +10,6 @@ namespace CarShowroomContracts.AbstractModels public interface IService : IId { string Name { get; } - int Cost { get; } + int Price { get; } } } diff --git a/CarShowroom/CarShowroomDataModels/Dtos/ServiceDto.cs b/CarShowroom/CarShowroomDataModels/Dtos/ServiceDto.cs index b307896..acfc589 100644 --- a/CarShowroom/CarShowroomDataModels/Dtos/ServiceDto.cs +++ b/CarShowroom/CarShowroomDataModels/Dtos/ServiceDto.cs @@ -11,12 +11,12 @@ namespace CarShowroomDataModels.Dtos { public int Id { get; set; } public string Name { get; set; } - public int Cost { get; set; } + public int Price { get; set; } public ServiceDto(IService model) { Id = model.Id; Name = model.Name; - Cost = model.Cost; + Price = model.Price; } } } diff --git a/CarShowroom/CarShowroomDataModels/Views/CarView.cs b/CarShowroom/CarShowroomDataModels/Views/CarView.cs index cd3f7a9..445bb27 100644 --- a/CarShowroom/CarShowroomDataModels/Views/CarView.cs +++ b/CarShowroom/CarShowroomDataModels/Views/CarView.cs @@ -12,8 +12,6 @@ namespace CarShowroomDataModels.Views { [DisplayName("Номер машины")] public int Id { get; set; } - [DisplayName("Название машины")] - public string Name { get; set; } = string.Empty; [DisplayName("Цвет")] public string Color { get; set; } [DisplayName("Дата производства")] @@ -22,7 +20,7 @@ namespace CarShowroomDataModels.Views [DisplayName("Модель")] public string ModelName { get; set; } = string.Empty; [DisplayName("Цена")] - public int ModelPrice { get; set; } + public int Price { get; set; } [DisplayName("Марка")] public string MakeName { get; set; } = string.Empty; [DisplayName("Продана")] diff --git a/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs b/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs index e2b6adc..2c17bf9 100644 --- a/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs +++ b/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs @@ -11,12 +11,12 @@ namespace CarShowroomDataModels.Views { public int Id { get; set; } public string Name { get; set; } - public int Cost { get; set; } + public int Price { get; set; } public ServiceView(IService model) { Id = model.Id; Name = model.Name; - Cost = model.Cost; + Price = model.Price; } public ServiceView() { } } diff --git a/CarShowroom/CarShowroomDatabaseStorage/CarShowroomDatabase.cs b/CarShowroom/CarShowroomDatabaseStorage/CarShowroomDatabase.cs index 8201042..9906eae 100644 --- a/CarShowroom/CarShowroomDatabaseStorage/CarShowroomDatabase.cs +++ b/CarShowroom/CarShowroomDatabaseStorage/CarShowroomDatabase.cs @@ -34,7 +34,7 @@ namespace CarShowroomDatabaseStorage modelBuilder.Entity().Property(e => e.Password).HasDefaultValue("empty_string"); modelBuilder.Entity().Property(c => c.Color).HasDefaultValue("empty_string"); modelBuilder.Entity().Property(c => c.IsSaled).HasDefaultValue(false); - modelBuilder.Entity().Property(c => c.Cost).HasDefaultValue(-1); + modelBuilder.Entity().Property(c => c.Price).HasDefaultValue(-1); modelBuilder.Entity().Property(c => c.Price).HasDefaultValue(-1); modelBuilder.Entity().Property(c => c.Cost).HasDefaultValue(-1); //on delete actions diff --git a/CarShowroom/CarShowroomDatabaseStorage/Entities/Car.cs b/CarShowroom/CarShowroomDatabaseStorage/Entities/Car.cs index 8069ad6..93b35cf 100644 --- a/CarShowroom/CarShowroomDatabaseStorage/Entities/Car.cs +++ b/CarShowroom/CarShowroomDatabaseStorage/Entities/Car.cs @@ -61,10 +61,9 @@ namespace CarShowroomDatabaseStorage.Entities public CarView GetView() { CarView car = new CarView(this); - car.ModelPrice = Model?.Price ?? 0; + car.Price = Model?.Price ?? 0; car.ModelName = Model?.Name ?? string.Empty; car.MakeName = Model?.Make?.Name ?? string.Empty; - car.Name = car.Color + " " + car.MakeName + " " + car.ModelName; return car; } } diff --git a/CarShowroom/CarShowroomDatabaseStorage/Entities/Service.cs b/CarShowroom/CarShowroomDatabaseStorage/Entities/Service.cs index bdb5ac8..b799e9a 100644 --- a/CarShowroom/CarShowroomDatabaseStorage/Entities/Service.cs +++ b/CarShowroom/CarShowroomDatabaseStorage/Entities/Service.cs @@ -24,7 +24,7 @@ namespace CarShowroomDatabaseStorage.Entities public string Name { get; private set; } = string.Empty; [Required] [Column("service_cost")] - public int Cost { get; private set; } + public int Price { get; private set; } public virtual List SaleServices { get; set; } = new(); private Service() { } @@ -33,7 +33,7 @@ namespace CarShowroomDatabaseStorage.Entities { Id = service.Id; Name = service.Name; - Cost = service.Cost; + Price = service.Price; } public static Service? Create(IService service) @@ -48,7 +48,7 @@ namespace CarShowroomDatabaseStorage.Entities if (service == null) return; Name = service.Name; - Cost = service.Cost; + Price = service.Price; } public ServiceView GetView() diff --git a/CarShowroom/CarShowroomDatabaseStorage/Storages/CarStorage.cs b/CarShowroom/CarShowroomDatabaseStorage/Storages/CarStorage.cs index c32d65c..af7bf8c 100644 --- a/CarShowroom/CarShowroomDatabaseStorage/Storages/CarStorage.cs +++ b/CarShowroom/CarShowroomDatabaseStorage/Storages/CarStorage.cs @@ -3,6 +3,7 @@ using CarShowroomDatabaseStorage.Entities; using CarShowroomDataModels.Dtos; using CarShowroomDataModels.SearchModel; using CarShowroomDataModels.Views; +using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; @@ -17,7 +18,9 @@ namespace CarShowroomDatabaseStorage.Storages { using var context = new CarShowroomDatabase(); return context.Cars - .Select(x => x.GetView()) + .Include(c => c.Model) + .ThenInclude(m => m.Make) + .Select(x => x.GetView()) .ToList(); } @@ -29,6 +32,8 @@ namespace CarShowroomDatabaseStorage.Storages } using var context = new CarShowroomDatabase(); return context.Cars + .Include(c => c.Model) + .ThenInclude(m => m.Make) .Where(x => !model.Id.HasValue || x.Id == model.Id) .Select(x => x.GetView()) .ToList(); diff --git a/CarShowroom/CarShowroomManagerApp/Controllers/HomeController.cs b/CarShowroom/CarShowroomManagerApp/Controllers/HomeController.cs index 1b6ae8f..ec32675 100644 --- a/CarShowroom/CarShowroomManagerApp/Controllers/HomeController.cs +++ b/CarShowroom/CarShowroomManagerApp/Controllers/HomeController.cs @@ -75,8 +75,8 @@ namespace CarShowroomManagerApp.Controllers return Redirect("~/Home/Enter"); } ViewBag.Cars = ApiClient.GetRequest>("api/car/getcarlist"); - ViewBag.Clients = ApiClient.GetRequest>("api/client/getclientlist"); - ViewBag.Services = ApiClient.GetRequest>("api/service/getservicelist"); + ViewBag.Clients = ApiClient.GetRequest>("api/client/getclientlist"); + ViewBag.Services = ApiClient.GetRequest>("api/service/getservicelist"); return View(); } @@ -132,7 +132,7 @@ namespace CarShowroomManagerApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Shops = ApiClient.GetRequest>("api/client/getclientlist"); + ViewBag.Clients = ApiClient.GetRequest>("api/client/getclientlist"); return View(); } @@ -154,7 +154,7 @@ namespace CarShowroomManagerApp.Controllers Name = name, PhoneNumber = phonenumber }); - Response.Redirect("Index"); + Response.Redirect("Clients"); } public IActionResult SaleDelete() @@ -163,7 +163,7 @@ namespace CarShowroomManagerApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Shops = ApiClient.GetRequest>("api/sale/getsalelist"); + ViewBag.Sales = ApiClient.GetRequest>("api/sale/getsalelist"); return View(); } diff --git a/CarShowroom/CarShowroomManagerApp/Views/Home/ClientUpdate.cshtml b/CarShowroom/CarShowroomManagerApp/Views/Home/ClientUpdate.cshtml index 3df884a..51a968f 100644 --- a/CarShowroom/CarShowroomManagerApp/Views/Home/ClientUpdate.cshtml +++ b/CarShowroom/CarShowroomManagerApp/Views/Home/ClientUpdate.cshtml @@ -6,6 +6,13 @@

Редактирование данных клиента

+
+
Клиент:
+
+ +
+
Номер телефона:
@@ -17,7 +24,7 @@
-
diff --git a/CarShowroom/CarShowroomManagerApp/Views/Home/SaleCreate.cshtml b/CarShowroom/CarShowroomManagerApp/Views/Home/SaleCreate.cshtml index 3c272a9..c3e126d 100644 --- a/CarShowroom/CarShowroomManagerApp/Views/Home/SaleCreate.cshtml +++ b/CarShowroom/CarShowroomManagerApp/Views/Home/SaleCreate.cshtml @@ -5,12 +5,12 @@

Продажа

-
+ @*
Сумма:
-
+
*@
Клиент:
@@ -24,7 +24,7 @@
@@ -35,7 +35,7 @@
diff --git a/CarShowroom/CarShowroomManagerApp/libman.json b/CarShowroom/CarShowroomManagerApp/libman.json new file mode 100644 index 0000000..ceee271 --- /dev/null +++ b/CarShowroom/CarShowroomManagerApp/libman.json @@ -0,0 +1,5 @@ +{ + "version": "1.0", + "defaultProvider": "cdnjs", + "libraries": [] +} \ No newline at end of file