DeliveriesOfDay FillForDay(DateTime day, Delivery[] deliveries) { var deliveriesForDay = new DeliveriesOfDay(day); var deliverers = deliveries.Select(d => d.Deliverer).Distinct().ToArray(); foreach (var deliverer in deliverers) { FillForDay(deliveriesForDay, deliverer, deliveries.Where(d => d.Deliverer.Equals(deliverer)).ToArray()); } return(deliveriesForDay); }
void FillForDay(DeliveriesOfDay deliveriesForDay, string deliverer, Delivery[] deliveries) { deliveriesForDay.DeliveriesPerDeliverer.Add(deliverer, deliveries); }