From f461b880dde6b6fe7ed90bbf1e3a80c3b3c18d93 Mon Sep 17 00:00:00 2001 From: kirinzx Date: Sun, 26 May 2024 15:36:25 +0400 Subject: [PATCH] cruds ready. DAITE TRI --- .../BusinessLogics/CarLogic.cs | 1 - .../BusinessLogics/EquipmentLogic.cs | 1 - .../BusinessLogics/PresellingWorkLogic.cs | 1 - .../BusinessLogics/PurchaseLogic.cs | 1 - .../BusinessLogics/UserLogic.cs | 1 - .../BusinessLogics/WishLogic.cs | 1 - .../BindingModels/CarBindingModel.cs | 2 +- .../BindingModels/EquipmentBindingModel.cs | 8 +- .../PresellingWorkBindingModel.cs | 6 +- .../BindingModels/WishBindingModel.cs | 6 +- .../Implements/CarStorage.cs | 8 +- .../Implements/EquipmentStorage.cs | 4 +- .../Implements/PresellingWorkStorage.cs | 4 +- .../Implements/PurchaseStorage.cs | 6 +- .../Implements/UserStorage.cs | 8 +- .../Implements/WishStorage.cs | 4 +- .../Migrations/20240525230104_Init.cs | 4 +- .../AutoCenterDatabaseImplement/Models/Car.cs | 4 +- .../Models/PresellingWork.cs | 8 +- .../Models/Purchase.cs | 10 +- .../Models/Wish.cs | 2 +- .../Controllers/HomeController.cs | 220 +++++++++++++++++- .../Views/Home/CreateCar.cshtml | 6 +- .../Views/Home/DeleteCar.cshtml | 2 +- .../Views/Home/DeleteEquipment.cshtml | 2 +- .../Views/Home/DeletePresellingWork.cshtml | 2 +- .../Views/Home/DeletePurchase.cshtml | 2 +- .../Views/Home/DeleteWish.cshtml | 2 +- .../Views/Home/Equipment.cshtml | 6 +- .../Views/Home/PresellingWork.cshtml | 6 +- .../Views/Home/UpdatePresellingWork.cshtml | 2 +- .../Views/Home/UpdatePurchase.cshtml | 2 +- .../Views/Shared/_Layout.cshtml | 16 +- 33 files changed, 279 insertions(+), 79 deletions(-) diff --git a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/CarLogic.cs b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/CarLogic.cs index e7c4a8f..20c15b9 100644 --- a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/CarLogic.cs +++ b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/CarLogic.cs @@ -72,7 +72,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics } public List? ReadList(CarSearchModel? model) { - _logger.LogInformation("ReadList. CarName:{CarName}.Id:{Id}", model.Name, model.Id); var list = model == null ? _CarStorage.GetFullList() : _CarStorage.GetFilteredList(model); diff --git a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/EquipmentLogic.cs b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/EquipmentLogic.cs index dc69561..c87dad3 100644 --- a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/EquipmentLogic.cs +++ b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/EquipmentLogic.cs @@ -72,7 +72,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics } public List? ReadList(EquipmentSearchModel? model) { - _logger.LogInformation("ReadList. Equipment:{Name}.Id:{Id}", model.Name, model.Id); var list = model == null ? _EquipmentStorage.GetFullList() : _EquipmentStorage.GetFilteredList(model); diff --git a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/PresellingWorkLogic.cs b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/PresellingWorkLogic.cs index cf3006b..d14e3ac 100644 --- a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/PresellingWorkLogic.cs +++ b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/PresellingWorkLogic.cs @@ -76,7 +76,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics public List? ReadList(PresellingWorkSearchModel? model) { - _logger.LogInformation("ReadList. PresellingWork:{Name}.Id:{Id}", model.Name, model.Id); var list = model == null ? _PresellingWorkStorage.GetFullList() : _PresellingWorkStorage.GetFilteredList(model); diff --git a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/PurchaseLogic.cs b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/PurchaseLogic.cs index 96b6392..b00adcc 100644 --- a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/PurchaseLogic.cs +++ b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/PurchaseLogic.cs @@ -72,7 +72,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics } public List? ReadList(PurchaseSearchModel? model) { - _logger.LogInformation("ReadList. Purchase: Id:{Id}", model.Id); var list = model == null ? _PurchaseStorage.GetFullList() : _PurchaseStorage.GetFilteredList(model); diff --git a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/UserLogic.cs b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/UserLogic.cs index dbc32ad..62bc8d0 100644 --- a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/UserLogic.cs +++ b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/UserLogic.cs @@ -76,7 +76,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics public List? ReadList(UserSearchModel? model) { - _logger.LogInformation("ReadList. UserEmail:{UserFIO}.Id:{Id}", model.Email, model.Id); var list = model == null ? _UserStorage.GetFullList() : _UserStorage.GetFilteredList(model); diff --git a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/WishLogic.cs b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/WishLogic.cs index d240e36..d867f48 100644 --- a/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/WishLogic.cs +++ b/AutoCenter/AutoCenterBusinessLogic/BusinessLogics/WishLogic.cs @@ -76,7 +76,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics public List? ReadList(WishSearchModel? model) { - _logger.LogInformation("ReadList. Wish:{Name}.Id:{Id}", model.Name, model.Id); var list = model == null ? _WishStorage.GetFullList() : _WishStorage.GetFilteredList(model); diff --git a/AutoCenter/AutoCenterContracts/BindingModels/CarBindingModel.cs b/AutoCenter/AutoCenterContracts/BindingModels/CarBindingModel.cs index 1918da9..b9feace 100644 --- a/AutoCenter/AutoCenterContracts/BindingModels/CarBindingModel.cs +++ b/AutoCenter/AutoCenterContracts/BindingModels/CarBindingModel.cs @@ -10,7 +10,7 @@ namespace AutoCenterContracts.BindingModels public class CarBindingModel : ICarModel { public int Id { get; set; } - public string Name { get; set; } + public string Name { get; set; } = string.Empty; public Dictionary CarEquipments { get; set; } = new(); } } diff --git a/AutoCenter/AutoCenterContracts/BindingModels/EquipmentBindingModel.cs b/AutoCenter/AutoCenterContracts/BindingModels/EquipmentBindingModel.cs index 57fa790..4b8133b 100644 --- a/AutoCenter/AutoCenterContracts/BindingModels/EquipmentBindingModel.cs +++ b/AutoCenter/AutoCenterContracts/BindingModels/EquipmentBindingModel.cs @@ -10,8 +10,8 @@ namespace AutoCenterContracts.BindingModels public class EquipmentBindingModel : IEquipmentModel { public int Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } - - } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + + } } diff --git a/AutoCenter/AutoCenterContracts/BindingModels/PresellingWorkBindingModel.cs b/AutoCenter/AutoCenterContracts/BindingModels/PresellingWorkBindingModel.cs index 129fbf0..91e5ec9 100644 --- a/AutoCenter/AutoCenterContracts/BindingModels/PresellingWorkBindingModel.cs +++ b/AutoCenter/AutoCenterContracts/BindingModels/PresellingWorkBindingModel.cs @@ -10,8 +10,8 @@ namespace AutoCenterContracts.BindingModels public class PresellingWorkBindingModel : IPresellingWorkModel { public int Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } - public int UserId { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public int UserId { get; set; } } } diff --git a/AutoCenter/AutoCenterContracts/BindingModels/WishBindingModel.cs b/AutoCenter/AutoCenterContracts/BindingModels/WishBindingModel.cs index 6565890..d270891 100644 --- a/AutoCenter/AutoCenterContracts/BindingModels/WishBindingModel.cs +++ b/AutoCenter/AutoCenterContracts/BindingModels/WishBindingModel.cs @@ -10,8 +10,8 @@ namespace AutoCenterContracts.BindingModels public class WishBindingModel : IWishModel { public int Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } - public int PresellingWorkId { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public int PresellingWorkId { get; set; } } } diff --git a/AutoCenter/AutoCenterDatabaseImplement/Implements/CarStorage.cs b/AutoCenter/AutoCenterDatabaseImplement/Implements/CarStorage.cs index 75e247a..88d9670 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Implements/CarStorage.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Implements/CarStorage.cs @@ -40,21 +40,21 @@ namespace AutoCenterDatabaseImplement.Implements using var context = new AutoCenterDatabase(); - return context.Cars.Include(x => x.Purchases).Include(x => x.Equipments).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + return context.Cars.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } public List GetFilteredList(CarSearchModel model) { using var context = new AutoCenterDatabase(); - return context.Cars.Include(x => x.Purchases).Include(x => x.Equipments).Where(x => ((!model.Id.HasValue || x.Id == model.Id) - && (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name) + return context.Cars.Where(x => ((!model.Id.HasValue || x.Id == model.Id) + && (string.IsNullOrEmpty(model.Name) || x.Name == model.Name) )).Select(x => x.GetViewModel).ToList(); } public List GetFullList() { using var context = new AutoCenterDatabase(); - return context.Cars.Include(x => x.Purchases).Include(x => x.Equipments).Select(x => x.GetViewModel).ToList(); + return context.Cars.Select(x => x.GetViewModel).ToList(); } public CarViewModel? Insert(CarBindingModel model) { diff --git a/AutoCenter/AutoCenterDatabaseImplement/Implements/EquipmentStorage.cs b/AutoCenter/AutoCenterDatabaseImplement/Implements/EquipmentStorage.cs index ae40248..7aab4f0 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Implements/EquipmentStorage.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Implements/EquipmentStorage.cs @@ -48,8 +48,8 @@ namespace AutoCenterDatabaseImplement.Implements using var context = new AutoCenterDatabase(); return context.Equipments.Include(x => x.Cars) - .Where(x => ((!model.Id.HasValue || x.Id == model.Id) && (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name) && - (!string.IsNullOrEmpty(model.Description) || x.Description == model.Description))) + .Where(x => ((!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Name) || x.Name == model.Name) && + (string.IsNullOrEmpty(model.Description) || x.Description == model.Description))) .Select(x => x.GetViewModel).ToList(); } diff --git a/AutoCenter/AutoCenterDatabaseImplement/Implements/PresellingWorkStorage.cs b/AutoCenter/AutoCenterDatabaseImplement/Implements/PresellingWorkStorage.cs index b408a96..cff4e75 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Implements/PresellingWorkStorage.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Implements/PresellingWorkStorage.cs @@ -49,8 +49,8 @@ namespace AutoCenterDatabaseImplement.Implements return context.PresellingWorks.Include(x => x.Wishes) .Where(x => ((!model.Id.HasValue || x.Id == model.Id) - && (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name) - && (!string.IsNullOrEmpty(model.Description) || x.Description == model.Description) + && (string.IsNullOrEmpty(model.Name) || x.Name == model.Name) + && (string.IsNullOrEmpty(model.Description) || x.Description == model.Description) && (!model.UserId.HasValue || x.UserId == model.UserId) )) .Select(x => x.GetViewModel).ToList(); diff --git a/AutoCenter/AutoCenterDatabaseImplement/Implements/PurchaseStorage.cs b/AutoCenter/AutoCenterDatabaseImplement/Implements/PurchaseStorage.cs index a4a7f27..4f5bcc9 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Implements/PurchaseStorage.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Implements/PurchaseStorage.cs @@ -39,13 +39,13 @@ namespace AutoCenterDatabaseImplement.Implements using var context = new AutoCenterDatabase(); - return context.Purchases.Include(x => x.PresellingWorks).Include(x => x.Cars).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + return context.Purchases.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } public List GetFilteredList(PurchaseSearchModel model) { using var context = new AutoCenterDatabase(); - return context.Purchases.Include(x => x.PresellingWorks).Include(x => x.Cars).Where(x => ((!model.Id.HasValue || x.Id == model.Id) + return context.Purchases.Where(x => ((!model.Id.HasValue || x.Id == model.Id) && (!model.IsCashPaid.HasValue || x.IsCashPaid == model.IsCashPaid) && (!model.UserId.HasValue || x.UserId == model.UserId) && (!model.Date.HasValue || x.Date == model.Date))) @@ -55,7 +55,7 @@ namespace AutoCenterDatabaseImplement.Implements { using var context = new AutoCenterDatabase(); - return context.Purchases.Include(x => x.PresellingWorks).Include(x => x.Cars).Select(x => x.GetViewModel).ToList(); + return context.Purchases.Select(x => x.GetViewModel).ToList(); } public PurchaseViewModel? Insert(PurchaseBindingModel model) { diff --git a/AutoCenter/AutoCenterDatabaseImplement/Implements/UserStorage.cs b/AutoCenter/AutoCenterDatabaseImplement/Implements/UserStorage.cs index a10540f..daa450c 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Implements/UserStorage.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Implements/UserStorage.cs @@ -51,10 +51,10 @@ namespace AutoCenterDatabaseImplement.Implements using var context = new AutoCenterDatabase(); return context.Users.Include(x => x.Purchases).Include(x => x.PresellingWorks).Where(x => ((!model.Id.HasValue || x.Id == model.Id) - && (!string.IsNullOrEmpty(model.Username) || x.Username == model.Username) - && (!string.IsNullOrEmpty(model.Password) || x.Password == model.Password) - && (!string.IsNullOrEmpty(model.PhoneNumber) || x.PhoneNumber == model.PhoneNumber) - && (!string.IsNullOrEmpty(model.Email) || x.Email == model.Email) + && (string.IsNullOrEmpty(model.Username) || x.Username == model.Username) + && (string.IsNullOrEmpty(model.Password) || x.Password == model.Password) + && (string.IsNullOrEmpty(model.PhoneNumber) || x.PhoneNumber == model.PhoneNumber) + && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email) )) .Select(x => x.GetViewModel).ToList(); } diff --git a/AutoCenter/AutoCenterDatabaseImplement/Implements/WishStorage.cs b/AutoCenter/AutoCenterDatabaseImplement/Implements/WishStorage.cs index c380ce5..140ba07 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Implements/WishStorage.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Implements/WishStorage.cs @@ -48,8 +48,8 @@ namespace AutoCenterDatabaseImplement.Implements using var context = new AutoCenterDatabase(); return context.Wishes.Where(x => ((!model.Id.HasValue || x.Id == model.Id) - && (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name) - && (!string.IsNullOrEmpty(model.Description) || x.Description == model.Description) + && (string.IsNullOrEmpty(model.Name) || x.Name == model.Name) + && (string.IsNullOrEmpty(model.Description) || x.Description == model.Description) && (!model.PresellingWorkId.HasValue || x.PresellingWorkId == model.PresellingWorkId) )) .Select(x => x.GetViewModel).ToList(); diff --git a/AutoCenter/AutoCenterDatabaseImplement/Migrations/20240525230104_Init.cs b/AutoCenter/AutoCenterDatabaseImplement/Migrations/20240525230104_Init.cs index 97dcb4f..db6ce8f 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Migrations/20240525230104_Init.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Migrations/20240525230104_Init.cs @@ -117,7 +117,7 @@ namespace AutoCenterDatabaseImplement.Migrations column: x => x.UserId, principalTable: "Users", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateTable( @@ -186,7 +186,7 @@ namespace AutoCenterDatabaseImplement.Migrations column: x => x.PurchasesId, principalTable: "Purchases", principalColumn: "Id", - onDelete: ReferentialAction.NoAction); + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( diff --git a/AutoCenter/AutoCenterDatabaseImplement/Models/Car.cs b/AutoCenter/AutoCenterDatabaseImplement/Models/Car.cs index f75ea57..8998199 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Models/Car.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Models/Car.cs @@ -45,9 +45,7 @@ namespace AutoCenterDatabaseImplement.Models { Id = model.Id, Name = model.Name, - Equipments = model.CarEquipments.Select(x => new Equipment { - Id = context.Equipments.First(y => y.Id == x.Key).Id - }).ToList(), + Equipments = model.CarEquipments.Select(x => context.Equipments.First(y => y.Id == x.Key)).ToList(), }; } public void Update(CarBindingModel? model) diff --git a/AutoCenter/AutoCenterDatabaseImplement/Models/PresellingWork.cs b/AutoCenter/AutoCenterDatabaseImplement/Models/PresellingWork.cs index b4c9a71..26e354f 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Models/PresellingWork.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Models/PresellingWork.cs @@ -21,7 +21,6 @@ namespace AutoCenterDatabaseImplement.Models public string Description { get; private set; } = string.Empty; [Required] public int UserId { get;private set; } - public virtual User User { get; set; } = new(); public List Wishes { get; set; } = new(); @@ -38,7 +37,8 @@ namespace AutoCenterDatabaseImplement.Models { Id = model.Id, Name = model.Name, - Description = model.Description + Description = model.Description, + UserId = model.UserId }; } @@ -52,13 +52,15 @@ namespace AutoCenterDatabaseImplement.Models Id = model.Id; Name = model.Name; Description = model.Description; + } public PresellingWorkViewModel GetViewModel => new() { Id = Id, Description = Description, - Name = Name + Name = Name, + UserId = UserId }; } } diff --git a/AutoCenter/AutoCenterDatabaseImplement/Models/Purchase.cs b/AutoCenter/AutoCenterDatabaseImplement/Models/Purchase.cs index 6b18aec..e4b2989 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Models/Purchase.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Models/Purchase.cs @@ -63,14 +63,8 @@ namespace AutoCenterDatabaseImplement.Models IsCashPaid = model.IsCashPaid, UserId = model.UserId, Date = model.Date, - Cars = model.PurchaseCars.Select(x => new Car - { - Id = context.Cars.First(y => y.Id == x.Key).Id - }).ToList(), - PresellingWorks = model.PurchasePresellingWorks.Select(x => new PresellingWork - { - Id = context.Equipments.First(y => y.Id == x.Key).Id - }).ToList() + Cars = model.PurchaseCars.Select(x => context.Cars.First(y => y.Id == x.Key)).ToList(), + PresellingWorks = model.PurchasePresellingWorks.Select(x => context.PresellingWorks.First(y => y.Id == x.Key)).ToList() }; } diff --git a/AutoCenter/AutoCenterDatabaseImplement/Models/Wish.cs b/AutoCenter/AutoCenterDatabaseImplement/Models/Wish.cs index b8884d5..2f7bc1f 100644 --- a/AutoCenter/AutoCenterDatabaseImplement/Models/Wish.cs +++ b/AutoCenter/AutoCenterDatabaseImplement/Models/Wish.cs @@ -21,7 +21,6 @@ namespace AutoCenterDatabaseImplement.Models public string Description { get; set; } = string.Empty; [Required] public int PresellingWorkId { get; set; } - public virtual PresellingWork PresellingWork { get; set; } = new(); public static Wish? Create(WishBindingModel model) { @@ -52,6 +51,7 @@ namespace AutoCenterDatabaseImplement.Models public WishViewModel GetViewModel => new() { Id = Id, + Name = Name, Description = Description, PresellingWorkId = PresellingWorkId }; diff --git a/AutoCenter/AutoCenterUserApp/Controllers/HomeController.cs b/AutoCenter/AutoCenterUserApp/Controllers/HomeController.cs index 81db8c6..b8a97c7 100644 --- a/AutoCenter/AutoCenterUserApp/Controllers/HomeController.cs +++ b/AutoCenter/AutoCenterUserApp/Controllers/HomeController.cs @@ -118,7 +118,7 @@ namespace AutoCenterUserApp.Controllers } ViewBag.Cars = APIUser.GetRequest>($"api/car/getcarlist"); - ViewBag.PresellingWorks = APIUser.GetRequest>($"api/presellignwork/getpresellingworklist?userid={APIUser.User.Id}"); + ViewBag.PresellingWorks = APIUser.GetRequest>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}"); return View(); } @@ -148,7 +148,7 @@ namespace AutoCenterUserApp.Controllers return Redirect("~/Home/Enter"); } - ViewBag.Purchases = APIUser.GetRequest>($"api/purchase/getpurchaseist?userid={APIUser.User.Id}"); + ViewBag.Purchases = APIUser.GetRequest>($"api/purchase/getpurchaselist?userid={APIUser.User.Id}"); return View(); } @@ -173,9 +173,9 @@ namespace AutoCenterUserApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Purchases = APIUser.GetRequest>($"api/purchase/getpurchaseist?userid={APIUser.User.Id}"); + ViewBag.Purchases = APIUser.GetRequest>($"api/purchase/getpurchaselist?userid={APIUser.User.Id}"); ViewBag.Cars = APIUser.GetRequest>($"api/car/getcarlist"); - ViewBag.PresellingWorks = APIUser.GetRequest>($"api/presellignwork/getpresellingworklist?userid={APIUser.User.Id}"); + ViewBag.PresellingWorks = APIUser.GetRequest>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}"); return View(); } @@ -187,7 +187,7 @@ namespace AutoCenterUserApp.Controllers throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); } - APIUser.PostRequest("api/student/updatepurchase", new PurchaseBindingModel + APIUser.PostRequest("api/purchase/updatepurchase", new PurchaseBindingModel { Id = purchaseId, IsCashPaid = isCashPaid, @@ -283,7 +283,7 @@ namespace AutoCenterUserApp.Controllers { return Redirect("~/Home/Enter"); } - + ViewBag.Wishes = APIUser.GetRequest>($"api/wish/getwishlist"); ViewBag.PresellingWorks = APIUser.GetRequest>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}"); return View(); } @@ -322,7 +322,7 @@ namespace AutoCenterUserApp.Controllers return result; } - // PresellingWork + // PresellingWorks public IActionResult PresellingWork() { if (APIUser.User == null) @@ -427,6 +427,212 @@ namespace AutoCenterUserApp.Controllers return result; } + // Cars + public IActionResult Car() + { + if (APIUser.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIUser.GetRequest>($"api/car/getcarlist")); + } + + public IActionResult CreateCar() + { + if (APIUser.User == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Equipments = APIUser.GetRequest>($"api/equipment/getequipmentlist"); + return View(); + } + + [HttpPost] + public void CreateCar(string name, List equipments) + { + if (APIUser.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + + + APIUser.PostRequest("api/car/createcar", new CarBindingModel + { + Name = name, + CarEquipments = equipments.ToDictionary(record => record, record => new EquipmentSearchModel { Id = record } as IEquipmentModel) + }); + Response.Redirect("Car"); + } + public IActionResult DeleteCar() + { + if (APIUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + ViewBag.Cars = APIUser.GetRequest>($"api/car/getcarlist"); + return View(); + } + public IActionResult UpdateCar() + { + if (APIUser.User == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Cars = APIUser.GetRequest>($"api/car/getcarlist"); + ViewBag.Equipments = APIUser.GetRequest>($"api/equipment/getequipmentlist"); + return View(); + } + + [HttpPost] + public void DeleteCar(int carId) + { + if (APIUser.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + APIUser.PostRequest("api/car/deletecar", new CarBindingModel + { + Id = carId + }); + Response.Redirect("Car"); + } + + [HttpPost] + public void UpdateCar(int carId, string name, List equipments) + { + if (APIUser.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + + APIUser.PostRequest("api/car/updatecar", new CarBindingModel + { + Id = carId, + Name = name, + CarEquipments = equipments.ToDictionary(record => record, record => new EquipmentSearchModel { Id = record } as IEquipmentModel) + }); + Response.Redirect("Car"); + } + + [HttpGet] + public PresellingWorkViewModel? GetCar(int carId) + { + if (APIUser.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + var result = APIUser.GetRequest($"api/car/getcar?carid={carId}"); + if (result == null) + { + return default; + } + + return result; + } + // Equipments + public IActionResult Equipment() + { + if (APIUser.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIUser.GetRequest>($"api/equipment/getequipmentlist")); + } + + public IActionResult CreateEquipment() + { + if (APIUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(); + } + + [HttpPost] + public void CreateEquipment(string name, string description) + { + if (APIUser.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + + + APIUser.PostRequest("api/equipment/createequipment", new EquipmentBindingModel + { + Name = name, + Description = description + }); + Response.Redirect("Equipment"); + } + public IActionResult DeleteEquipment() + { + if (APIUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + ViewBag.Equipments = APIUser.GetRequest>($"api/equipment/getequipmentlist"); + return View(); + } + public IActionResult UpdateEquipment() + { + if (APIUser.User == null) + { + return Redirect("~/Home/Enter"); + } + + ViewBag.Equipments = APIUser.GetRequest>($"api/equipment/getequipmentlist"); + return View(); + } + + [HttpPost] + public void DeleteEquipment(int equipmentId) + { + if (APIUser.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + APIUser.PostRequest("api/equipment/deleteequipment", new EquipmentBindingModel + { + Id = equipmentId + }); + Response.Redirect("Equipment"); + } + + [HttpPost] + public void UpdateEquipment(int equipmentId, string name, string description) + { + if (APIUser.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + + APIUser.PostRequest("api/equipment/updateequipment", new EquipmentBindingModel + { + Id = equipmentId, + Name = name, + Description = description + }); + Response.Redirect("Equipment"); + } + + [HttpGet] + public EquipmentViewModel? GetEquipment(int equipmentId) + { + if (APIUser.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + var result = APIUser.GetRequest($"api/equipment/getequipment?equipmentid={equipmentId}"); + if (result == null) + { + return default; + } + + return result; + } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/CreateCar.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/CreateCar.cshtml index f9141d4..f6791e6 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/CreateCar.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/CreateCar.cshtml @@ -1,9 +1,9 @@ @{ - ViewData["Title"] = "CreateCertification"; + ViewData["Title"] = "CreateСфк"; }
-

Создание аттестации

+

Создание машины

@@ -15,7 +15,7 @@
Комплектации:
- +
diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/DeleteCar.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/DeleteCar.cshtml index 3f86669..eef8c80 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/DeleteCar.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/DeleteCar.cshtml @@ -8,7 +8,7 @@
Машина:
- +
diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/DeleteEquipment.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/DeleteEquipment.cshtml index 55b3998..ee74ea2 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/DeleteEquipment.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/DeleteEquipment.cshtml @@ -8,7 +8,7 @@
Комплектация:
- +
diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/DeletePresellingWork.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/DeletePresellingWork.cshtml index 29cffd3..5966434 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/DeletePresellingWork.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/DeletePresellingWork.cshtml @@ -8,7 +8,7 @@
Препродажная работа:
- +
diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/DeletePurchase.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/DeletePurchase.cshtml index 3c52796..a451238 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/DeletePurchase.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/DeletePurchase.cshtml @@ -8,7 +8,7 @@
Покупка:
- +
diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/DeleteWish.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/DeleteWish.cshtml index 8d1e420..072546a 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/DeleteWish.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/DeleteWish.cshtml @@ -8,7 +8,7 @@
Пожелание:
- +
diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/Equipment.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/Equipment.cshtml index 5a5df49..2e8bfb6 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/Equipment.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/Equipment.cshtml @@ -14,9 +14,9 @@ return; }

- Создать Комплектацию - Обновить Комплектацию - Удалить Комплектацию + Создать Комплектацию + Обновить Комплектацию + Удалить Комплектацию

diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/PresellingWork.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/PresellingWork.cshtml index 7ab912a..5f39479 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/PresellingWork.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/PresellingWork.cshtml @@ -14,9 +14,9 @@ return; }

- Создать предпродажную работу - Обновить предпродажную работу - Удалить предпродажную работу + Создать предпродажную работу + Обновить предпродажную работу + Удалить предпродажную работу Связать пожелание и предродажюную работу

diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/UpdatePresellingWork.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/UpdatePresellingWork.cshtml index 9647979..8427b64 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/UpdatePresellingWork.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/UpdatePresellingWork.cshtml @@ -10,7 +10,7 @@
Предпродажная работа:
- +
diff --git a/AutoCenter/AutoCenterUserApp/Views/Home/UpdatePurchase.cshtml b/AutoCenter/AutoCenterUserApp/Views/Home/UpdatePurchase.cshtml index a249850..4dcf62c 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Home/UpdatePurchase.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Home/UpdatePurchase.cshtml @@ -11,7 +11,7 @@
Покупка:
- +
diff --git a/AutoCenter/AutoCenterUserApp/Views/Shared/_Layout.cshtml b/AutoCenter/AutoCenterUserApp/Views/Shared/_Layout.cshtml index af2bc0e..1c2ddcf 100644 --- a/AutoCenter/AutoCenterUserApp/Views/Shared/_Layout.cshtml +++ b/AutoCenter/AutoCenterUserApp/Views/Shared/_Layout.cshtml @@ -13,7 +13,7 @@