/// <inheritdoc /> public IEnumerable <NewPurchaseItemDto> GetOrderedPurchaseItems(IEnumerable <ExistingRecipeDto> existingRecipeDtos, ExistingStoreDto existingStoreDto) { var recipes = SimpleCrudHelper.FindMany <Recipe>(existingRecipeDtos.Select(x => x.RecipeId)); var store = SimpleCrudHelper.Find <Store>(existingStoreDto.StoreId); var orderedPurchaseItemsByStore = OrderPurchaseItemsByStoreAction.OrderPurchaseItemsByStore(store, GeneratePurchaseItemsForRecipesAction .GeneratePurchaseItems(recipes)); return(Mapper.Map <IEnumerable <NewPurchaseItemDto> >(orderedPurchaseItemsByStore)); }
/// <inheritdoc /> public IEnumerable <NewPurchaseItemDto> GetOrderedPurchaseItems(ExistingStoreDto existingStoreDto) { var meals = Context.Meals.Where(x => !x.HasBeenShopped); var recipes = GetRecipesForMealsAction.GetRecipesForMeals(meals); var store = SimpleCrudHelper.Find <Store>(existingStoreDto.StoreId); var orderedPurchaseItemsByStore = OrderPurchaseItemsByStoreAction.OrderPurchaseItemsByStore(store, GeneratePurchaseItemsForRecipesAction .GeneratePurchaseItems(recipes)); foreach (var meal in meals) { meal.HasBeenShopped = true; } var newPurchaseItemDtos = Mapper.Map <IEnumerable <NewPurchaseItemDto> >(orderedPurchaseItemsByStore); // TODO MUL: Investigate why conversion has to be done before calling SaveChanges() Context.SaveChanges(); return(newPurchaseItemDtos); }