using demo_trade.Data.Repository; using demo_trade.Models; using demo_trade.UI.Presenters; using demo_trade.Utils; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace demo_trade.Domain { public class GuestProductUseCase { private IProductRepository _productRepository; public GuestProductUseCase(IProductRepository productRepository) { _productRepository = productRepository; } public List GetProducts() => _productRepository .GetProducts() .Select(it => new ProductPresenter { ArticleNumber = it.Productarticlenumber, Description = it.Productdescription, Name = it.Productname, DiscountAmount = it.Productdiscountamount, Cost = it.Productcost == null ? 0 : Convert.ToDecimal(it.Productcost), ProductMaxDiscount = it.Productmaxdiscount, QuantityInStock = it.Productquantityinstock, Manufacturer = new Manufacturer { Id = it.Manufacturer.ManufacturerId, Name = it.Manufacturer.ManufacturerName }, Image = !String.IsNullOrEmpty(it.Imagename) ? ImageHelper.BASE_URL + "/" + it.Imagename : ImageHelper.BASE_URL + "/" + "default.png" , }).ToList(); } }