reactredux/webapi/WeatherForecast/Models/Responses/GetShopCartItemResponseModel.cs

40 lines
1.2 KiB
C#

using Core.Abstractions.Models;
using Core.DomainObjects.Documents;
using Core.Enumerations;
namespace WeatherForecast.Models.Responses {
public class GetShopCartItemResponseModel : ResponseModelBase {
public string Slug { get; set; }
public string Sku { get; set; }
public ImageModel Image { get; set; }
public string Title { get; set; }
public string BrandName { get; set; }
public string ShortText { get; set; }
public DateTime Created { get; set; }
public decimal Price { get; set; }
public decimal? NewPrice { get; set; }
public uint? Quantity { get; set; }
public GetShopCartItemResponseModel() { }
public GetShopCartItemResponseModel(ShopItem shopItem, ShopCartItem shopCartItem, Locales locale) {
Sku = shopItem.Sku;
BrandName = shopItem.BrandName;
Created = shopItem.Created;
Price = shopItem.Price;
NewPrice = shopItem.NewPrice;
Quantity = shopCartItem.Quantity;
var shopItemL10n = shopItem.L10n.Single(x => x.Locale == locale);
Slug = shopItemL10n.Slug;
Title = shopItemL10n.Title;
ShortText = shopItemL10n.ShortText;
Image = new ImageModel(shopItem.Images.First(), locale);
}
}
}