public async Task Compute(SaleHeader saleHeader) { List <Beer> beers = (await _beerRepository.PricesListAsync(saleHeader.SaleLines.AsEnumerable().Select(x => x.BeerId).ToList())).ToList(); foreach (SaleLine saleLine in saleHeader.SaleLines) { saleLine.UnitPrice = beers.AsEnumerable().Where(x => x.Id == saleLine.BeerId).First().Price; } saleHeader.Compute(); }
public void Create(SaleHeader saleHeader) { saleHeader.Compute(); _context.Sales.Add(saleHeader); }