public IEnumerable <StockEventViewModel> GetBatchEvents(string batchId, string eventTypeName) { var etype = m_eventRepository.GetAllEventTypes().FirstOrDefault(etp => etp.TabTitle == eventTypeName).Ensure(); var rawEvents = m_eventRepository.GetBatchEvents(BatchKey.Parse(batchId)) .Where(e => e.TypeId == etype.Id) .Select(e => new StockEventViewModel(e)); var result = new List <StockEventViewModel>(); foreach (var rawEvent in rawEvents) { var sameGrpEvt = result.FirstOrDefault(e => e.GroupingKey.Equals(rawEvent.GroupingKey)); if (sameGrpEvt != null) { sameGrpEvt.Join(rawEvent, m_amountProcessor); continue; } result.Add(rawEvent); } return(result); }
private void PopulateStockEventCounts(BatchReportEntry batchReportEntry) { foreach (var evt in m_stockEventRepository.GetBatchEvents(batchReportEntry.BatchKey)) { int sum; if (!batchReportEntry.StockEventCounts.TryGetValue(evt.Type.TabTitle, out sum)) { sum = 0; } batchReportEntry.StockEventCounts[evt.Type.TabTitle] = sum + 1; } }