public async Task Handle(VerifyRoutePlanIsComplete message) { var groupedTasks = Data.ShippingActivities .GroupBy(x => x.RouteId) .SelectMany(routeList => { var firstActivity = routeList.First(); var activitiesForEachAddress = routeList.GroupBy(x => x.AddressId).Select(group => { var groupedActivities = new ShippingActivity { Address = firstActivity.Address, AddressId = firstActivity.AddressId, Packages = group.SelectMany(x => x.Packages).ToList(), RouteId = firstActivity.RouteId }; return(groupedActivities); }); return(activitiesForEachAddress); }); await SomeOtherAsyncOperation(groupedTasks); MarkAsComplete(); }
public void AddShippingActivity(ShippingActivity shippingActivity) { ShippingActivities.Add(shippingActivity); }