редактирование доделать
This commit is contained in:
parent
bd9ec0284a
commit
7103e43d37
@ -80,6 +80,7 @@ namespace SushiBarDatabaseImplement.Models
|
|||||||
{ // удалили те, которых нет в модели
|
{ // удалили те, которых нет в модели
|
||||||
context.ShopSushi.RemoveRange(shopSushi.Where(rec => !model.ListSushi.ContainsKey(rec.SushiId)));
|
context.ShopSushi.RemoveRange(shopSushi.Where(rec => !model.ListSushi.ContainsKey(rec.SushiId)));
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
shopSushi = context.ShopSushi.Where(rec => rec.ShopId == model.Id).ToList();
|
||||||
// обновили количество у существующих записей
|
// обновили количество у существующих записей
|
||||||
foreach (var updateSushi in shopSushi)
|
foreach (var updateSushi in shopSushi)
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,8 @@ namespace SushiBarDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
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);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,14 @@ namespace SushiBarRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Tuple<ShopViewModel, Dictionary<int, (ISushiModel, int)>>? GetShop(int shopId)
|
public Tuple<ShopViewModel, List<Tuple<string, int>>>? GetShop(int shopId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var elem = _shop.ReadElement(new ShopSearchModel { Id = shopId });
|
var elem = _shop.ReadElement(new ShopSearchModel { Id = shopId });
|
||||||
if (elem == null)
|
if (elem == null)
|
||||||
return 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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -155,14 +155,28 @@ namespace SushiBarShopApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Tuple<ShopViewModel, Dictionary<int, (ISushiModel, int)>>? GetShop(int shopId)
|
public Tuple<ShopViewModel, string>? GetShop(int shopId)
|
||||||
{
|
{
|
||||||
if (APIClient.Access == false)
|
if (APIClient.Access == false)
|
||||||
{
|
{
|
||||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||||
}
|
}
|
||||||
var result = APIClient.GetRequest<Tuple<ShopViewModel, Dictionary<int, (ISushiModel, int)>>>($"api/shop/getshop?shopid={shopId}");
|
var result = APIClient.GetRequest<Tuple<ShopViewModel, List<Tuple<string, int>>>>($"api/shop/getshop?shopid={shopId}");
|
||||||
return result;
|
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 += "<tr>";
|
||||||
|
table += $"<td>{sushi}</td>";
|
||||||
|
table += $"<td>{count}</td>";
|
||||||
|
table += "</tr>";
|
||||||
|
}
|
||||||
|
return Tuple.Create(result.Item1, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult AddSushi()
|
public IActionResult AddSushi()
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="table">
|
<tbody id="table-elements">
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@ -69,7 +69,7 @@
|
|||||||
$('#address').val(result.item1.address);
|
$('#address').val(result.item1.address);
|
||||||
$('#date').val(result.item1.dateOpening);
|
$('#date').val(result.item1.dateOpening);
|
||||||
$('#count').val(result.item1.maxCountSushi);
|
$('#count').val(result.item1.maxCountSushi);
|
||||||
$('#table').html(result.item2);
|
$('#table-elements').html(result.item2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user