Merge branch 'Lab5_Hard' into Lab6_Hard

This commit is contained in:
shadowik 2023-05-04 10:36:14 +04:00
commit b4e81d4ee3
3 changed files with 11 additions and 4 deletions

View File

@ -100,6 +100,8 @@ namespace PizzeriaBusinessLogic.BusinessLogics
{ {
throw new ArgumentException("Магазина не существует"); throw new ArgumentException("Магазина не существует");
} }
if (shop.ShopPizzas.ContainsKey(model.PizzaId)) if (shop.ShopPizzas.ContainsKey(model.PizzaId))
{ {
var oldValue = shop.ShopPizzas[model.PizzaId]; var oldValue = shop.ShopPizzas[model.PizzaId];

View File

@ -1,4 +1,5 @@
using System; using PizzeriaDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -8,7 +9,7 @@ namespace PizzeriaContracts.ViewModels
{ {
public class PizzaCount public class PizzaCount
{ {
public PizzaViewModel Pizza { get; set; } = new(); public PizzaViewModel Pizza { get; set; }
public int Count { get; set; } = new(); public int Count { get; set; } = new();
} }

View File

@ -61,7 +61,11 @@ namespace PizzeriaShopRestApi.Controllers
return new ShopPizzaViewModel return new ShopPizzaViewModel
{ {
Shop = shop, 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) catch (Exception ex)
@ -108,7 +112,7 @@ namespace PizzeriaShopRestApi.Controllers
} }
[HttpDelete] [HttpDelete]
public void DeleteShop(int shopId,string password) public void DeleteShop(int shopId, string password)
{ {
if (!CheckPassword(password)) if (!CheckPassword(password))
{ {