public OutputDataProcessor(ILogger <OutputDataProcessor> logger, IRabbitMqClientPublisher clientPublisher, IConfiguration configuration, SalesProcessorDbContext context) { _logger = logger; _clientPublisher = clientPublisher; _configuration = configuration; _context = context; }
public static OutputDataDto GetIdFromMostExpensiveSale(this OutputDataDto outputDto, FileContentDto contentDto , SalesProcessorDbContext context) { var sales = context.Sales.Where(s => s.InputFileName == contentDto.InputFile.FileName).ToList(); var results = new List <Tuple <int, float> >(); sales.ForEach(s => { s.SalesInfo = context.SalesInfo.Where(info => info.FkSale == s.Id).ToList(); var price = s.SalesInfo.Sum(saleInfo => saleInfo.ItemPrice); results.Add(Tuple.Create(s.SaleId, price)); }); results = results.OrderByDescending(x => x.Item2).ToList(); outputDto.MostExpensiveSale = results.First().Item1; return(outputDto); }
public SalesDataProcessor(ILogger <SalesDataProcessor> logger, SalesProcessorDbContext context, IOutputDataProcessor processor) { _logger = logger; _context = context; _processor = processor; }