public IEnumerable <GetOfferModel> GetAll(bool activeOnly) { IEnumerable <OfferDto> allOffers = _offersRepository.GetAll(activeOnly); List <GetOfferModel> result = new List <GetOfferModel>(); foreach (var offer in allOffers) { GetOfferModel mappedOffer = _mapper.Map <OfferDto, GetOfferModel>(offer); result.Add(mappedOffer); } return(result); }
public async Task <List <OfferWithProductDetails> > GetNavigationList() { var offers = _offerRepository.GetAll().ToList(); var productsDict = _productRepository.Get(offers.Select(x => x.ProductId).Distinct()).ToDictionary(x => x.Id); var result = offers.Select(singleOffer => new OfferWithProductDetails { Id = singleOffer.Id, Cost = singleOffer.Cost, DefaultMargin = singleOffer.DefaultMargin, ProductName = productsDict.ContainsKey(singleOffer.ProductId)?productsDict[singleOffer.ProductId].Name:string.Empty }).ToList(); return(result); }
public List <Offer> GetAll() { return(_offersRepository.GetAll()); }