Merge branch 'lab5_hard' into lab6_hard
This commit is contained in:
commit
31b2f3cde3
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
@ -17,9 +18,11 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
public string Address { get; set; } = string.Empty;
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpening { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
|
||||
[DisplayName("Вместимость")]
|
||||
public int MaxCount { get; set; }
|
||||
|
||||
public List<FurnitureCountViewModel>? FurnituresCount { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModelWeb
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название магазина")]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
[DisplayName("Адрес магазина")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpening { get; set; }
|
||||
public List<FurnitureCountViewModel>? Furnitures { get; set; } = new();
|
||||
public int MaxCount { get; set; }
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ namespace FurnitureAssemblyRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ShopViewModelWeb? GetShop(int shopId)
|
||||
public ShopViewModel? GetShop(int shopId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -49,16 +49,10 @@ namespace FurnitureAssemblyRestApi.Controllers
|
||||
});
|
||||
if (shop == null)
|
||||
return null;
|
||||
var shopWeb = new ShopViewModelWeb
|
||||
{
|
||||
Id = shop.Id,
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpening = shop.DateOpening,
|
||||
Furnitures = shop.Furnitures.Select(x => x.Value).Select(x => new FurnitureCountViewModel { furniture = x.Item1.FurnitureName, Count = x.Item2 }).ToList(),
|
||||
MaxCount = shop.MaxCount
|
||||
};
|
||||
return shopWeb;
|
||||
|
||||
shop.FurnituresCount = shop.Furnitures.Select(x => x.Value)
|
||||
.Select(x => new FurnitureCountViewModel { furniture = x.Item1.FurnitureName, Count = x.Item2 }).ToList();
|
||||
return shop;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -139,9 +139,9 @@ namespace FurnitureAssemblyShopWorkApp.Controllers
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public ShopViewModelWeb? GetShop(int shopId)
|
||||
public ShopViewModel? GetShop(int shopId)
|
||||
{
|
||||
return APIClient.GetRequest<ShopViewModelWeb>($"api/shop/getshop?shopId={shopId}");
|
||||
return APIClient.GetRequest<ShopViewModel>($"api/shop/getshop?shopId={shopId}");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
|
@ -56,8 +56,8 @@
|
||||
$("#shopName").val(result.shopName);
|
||||
$("#dateOpening").val(new Date(result.dateOpening).toISOString().substring(0, 16));
|
||||
$("#address").val(result.address);
|
||||
$("#count").val(result.maxCount);
|
||||
fillTable(result.furnitures);
|
||||
$("#count").val(result.maxCount);
|
||||
fillTable(result.furnituresCount);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user