From d0f477cbb740eec913c05f9d9fa45755b56297c7 Mon Sep 17 00:00:00 2001 From: shadowik Date: Thu, 4 May 2023 08:57:52 +0400 Subject: [PATCH] Fix names --- .../PizzeriaBusinessLogic/BusinessLogics/ShopLogic.cs | 2 ++ Pizzeria/PizzeriaContracts/ViewModels/PizzaCount.cs | 5 +++-- .../PizzeriaShopRestApi/Controllers/ShopController.cs | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ShopLogic.cs b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ShopLogic.cs index b7b2ef3..e02187c 100644 --- a/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ShopLogic.cs +++ b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ShopLogic.cs @@ -100,6 +100,8 @@ namespace PizzeriaBusinessLogic.BusinessLogics { throw new ArgumentException("Магазина не существует"); } + + if (shop.ShopPizzas.ContainsKey(model.PizzaId)) { var oldValue = shop.ShopPizzas[model.PizzaId]; diff --git a/Pizzeria/PizzeriaContracts/ViewModels/PizzaCount.cs b/Pizzeria/PizzeriaContracts/ViewModels/PizzaCount.cs index a990e0c..64e6024 100644 --- a/Pizzeria/PizzeriaContracts/ViewModels/PizzaCount.cs +++ b/Pizzeria/PizzeriaContracts/ViewModels/PizzaCount.cs @@ -1,4 +1,5 @@ -using System; +using PizzeriaDataModels.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,7 +9,7 @@ namespace PizzeriaContracts.ViewModels { public class PizzaCount { - public PizzaViewModel Pizza { get; set; } = new(); + public PizzaViewModel Pizza { get; set; } public int Count { get; set; } = new(); } diff --git a/Pizzeria/PizzeriaShopRestApi/Controllers/ShopController.cs b/Pizzeria/PizzeriaShopRestApi/Controllers/ShopController.cs index 2b0e9b8..73614d7 100644 --- a/Pizzeria/PizzeriaShopRestApi/Controllers/ShopController.cs +++ b/Pizzeria/PizzeriaShopRestApi/Controllers/ShopController.cs @@ -61,7 +61,11 @@ namespace PizzeriaShopRestApi.Controllers return new ShopPizzaViewModel { Shop = shop, - ShopPizza = shop?.ShopPizzas?.ToDictionary(x => x.Key, x => new PizzaCount{ Pizza = x.Value.Item1 as PizzaViewModel, Count = x.Value.Item2 }) + ShopPizza = shop.ShopPizzas.ToDictionary(x => x.Key, x => new PizzaCount { Pizza = new PizzaViewModel() { Id = x.Value.Item1.Id, + PizzaName = x.Value.Item1.PizzaName, + PizzaComponents = x.Value.Item1.PizzaComponents, + Price = x.Value.Item1.Price, + }, Count = x.Value.Item2 }) }; } catch (Exception ex) @@ -108,7 +112,7 @@ namespace PizzeriaShopRestApi.Controllers } [HttpDelete] - public void DeleteShop(int shopId,string password) + public void DeleteShop(int shopId, string password) { if (!CheckPassword(password)) {