Вот теперь всё работает

This commit is contained in:
Николай 2023-04-09 23:24:30 +04:00
parent 744fb0f027
commit 4178c24cd2
3 changed files with 11 additions and 7 deletions

View File

@ -85,7 +85,10 @@ namespace FoodOrdersDatabaseImplement.Implements
} }
updateShop.Update(model); updateShop.Update(model);
context.SaveChanges(); context.SaveChanges();
updateShop.UpdateDish(context, model); if (model.ShopDishes.Count != 0)
{
updateShop.UpdateDish(context, model);
}
transaction.Commit(); transaction.Commit();
return updateShop.GetViewModel; return updateShop.GetViewModel;
} }

View File

@ -1,5 +1,6 @@
using FoodOrdersContracts.BindingModels; using FoodOrdersContracts.BindingModels;
using FoodOrdersContracts.BusinessLogicsContracts; using FoodOrdersContracts.BusinessLogicsContracts;
using FoodOrdersContracts.SearchModels;
using FoodOrdersContracts.ViewModels; using FoodOrdersContracts.ViewModels;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Text.Json; using System.Text.Json;
@ -83,9 +84,9 @@ namespace FoodOrdersRestApi.Controllers
public void DeleteShop(ShopBindingModel model) => CRUDShop(() => _logic.Delete(model)); public void DeleteShop(ShopBindingModel model) => CRUDShop(() => _logic.Delete(model));
[HttpPost] [HttpPost]
public void AddDishInShop(Tuple<DishViewModel, int> countDishForShop) public void AddDishInShop(Tuple<ShopSearchModel, DishViewModel, int> countDishForShop)
{ {
CRUDShop(() => _logic.AddDishes(countDishForShop.Item1, countDishForShop.Item2)); CRUDShop(() => _logic.DeliveryDishes(countDishForShop.Item1, countDishForShop.Item2, countDishForShop.Item3));
} }
} }
} }

View File

@ -70,7 +70,7 @@ namespace FoodOrdersShopApp.Controllers
} }
[HttpPost] [HttpPost]
public void Create(string shopname, string address, int maxCount) public void Create(string name, string address, int maxCount)
{ {
if (APIClient.IsAccessAllowed is false) if (APIClient.IsAccessAllowed is false)
{ {
@ -80,7 +80,7 @@ namespace FoodOrdersShopApp.Controllers
{ {
throw new Exception("Количество и сумма должны быть больше 0"); throw new Exception("Количество и сумма должны быть больше 0");
} }
if (string.IsNullOrEmpty(shopname)) if (string.IsNullOrEmpty(name))
{ {
throw new Exception($"Имя магазина не должно быть пустым"); throw new Exception($"Имя магазина не должно быть пустым");
} }
@ -90,7 +90,7 @@ namespace FoodOrdersShopApp.Controllers
} }
APIClient.PostRequest("api/shop/createshop", new ShopBindingModel APIClient.PostRequest("api/shop/createshop", new ShopBindingModel
{ {
ShopName = shopname, ShopName = name,
Address = address, Address = address,
Capacity = maxCount, Capacity = maxCount,
}); });