diff --git a/SushiBar/SushiBarDatabaseImplement/Models/Shop.cs b/SushiBar/SushiBarDatabaseImplement/Models/Shop.cs index f7ac029..54482fc 100644 --- a/SushiBar/SushiBarDatabaseImplement/Models/Shop.cs +++ b/SushiBar/SushiBarDatabaseImplement/Models/Shop.cs @@ -80,6 +80,7 @@ namespace SushiBarDatabaseImplement.Models { // удалили те, которых нет в модели context.ShopSushi.RemoveRange(shopSushi.Where(rec => !model.ListSushi.ContainsKey(rec.SushiId))); context.SaveChanges(); + shopSushi = context.ShopSushi.Where(rec => rec.ShopId == model.Id).ToList(); // обновили количество у существующих записей foreach (var updateSushi in shopSushi) { diff --git a/SushiBar/SushiBarDatabaseImplement/SushiBarDatabase.cs b/SushiBar/SushiBarDatabaseImplement/SushiBarDatabase.cs index 237eb71..5d56115 100644 --- a/SushiBar/SushiBarDatabaseImplement/SushiBarDatabase.cs +++ b/SushiBar/SushiBarDatabaseImplement/SushiBarDatabase.cs @@ -9,7 +9,8 @@ namespace SushiBarDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D8KMQQU\SQLEXPRESS;Initial Catalog=SushiBarDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + // D8KMQQU comp JC256C6 nout + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-JC256C6\SQLEXPRESS;Initial Catalog=SushiBarDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/SushiBar/SushiBarRestApi/Controllers/ShopController.cs b/SushiBar/SushiBarRestApi/Controllers/ShopController.cs index b6321ac..db72cf6 100644 --- a/SushiBar/SushiBarRestApi/Controllers/ShopController.cs +++ b/SushiBar/SushiBarRestApi/Controllers/ShopController.cs @@ -37,14 +37,14 @@ namespace SushiBarRestApi.Controllers } [HttpGet] - public Tuple>? GetShop(int shopId) + public Tuple>>? GetShop(int shopId) { try { var elem = _shop.ReadElement(new ShopSearchModel { Id = shopId }); if (elem == null) return null; - return Tuple.Create(elem, elem.ListSushi); + return Tuple.Create(elem, elem.ListSushi.Select(x => Tuple.Create(x.Value.Item1.SushiName, x.Value.Item2)).ToList()); } catch (Exception ex) { diff --git a/SushiBar/SushiBarShopApp/Controllers/HomeController.cs b/SushiBar/SushiBarShopApp/Controllers/HomeController.cs index ac1fe00..0737069 100644 --- a/SushiBar/SushiBarShopApp/Controllers/HomeController.cs +++ b/SushiBar/SushiBarShopApp/Controllers/HomeController.cs @@ -155,14 +155,28 @@ namespace SushiBarShopApp.Controllers } [HttpGet] - public Tuple>? GetShop(int shopId) + public Tuple? GetShop(int shopId) { if (APIClient.Access == false) { throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); } - var result = APIClient.GetRequest>>($"api/shop/getshop?shopid={shopId}"); - return result; + var result = APIClient.GetRequest>>>($"api/shop/getshop?shopid={shopId}"); + if (result == null) + { + return default; + } + string table = ""; + for (int i = 0; i < result.Item2.Count; i++) + { + var sushi = result.Item2[i].Item1; + var count = result.Item2[i].Item2; + table += ""; + table += $"{sushi}"; + table += $"{count}"; + table += ""; + } + return Tuple.Create(result.Item1, table); } public IActionResult AddSushi() diff --git a/SushiBar/SushiBarShopApp/Views/Home/Update.cshtml b/SushiBar/SushiBarShopApp/Views/Home/Update.cshtml index fddb343..58c39a5 100644 --- a/SushiBar/SushiBarShopApp/Views/Home/Update.cshtml +++ b/SushiBar/SushiBarShopApp/Views/Home/Update.cshtml @@ -49,7 +49,7 @@ - + @@ -69,7 +69,7 @@ $('#address').val(result.item1.address); $('#date').val(result.item1.dateOpening); $('#count').val(result.item1.maxCountSushi); - $('#table').html(result.item2); + $('#table-elements').html(result.item2); } }); };