예제 #1
0
        public async Task <IActionResult> ReorderRecipeActionGroup(string id, string actionGroupId,
                                                                   UpdateActionGroupOrderViewModel vm)
        {
            var recipe = await _recipeManager.GetRecipe(id, _userManager.GetUserId(User));

            if (recipe == null || !
                recipe.RecipeActionGroups.Any(group =>
                                              group.Id.Equals(actionGroupId, StringComparison.InvariantCultureIgnoreCase)))
            {
                return(GetNotFoundActionResult());
            }

            await _recipeManager.ReorderRecipeActionGroupActions(actionGroupId,
                                                                 vm.UpdateActionGroupOrderItems.ToDictionary(item => item.RecipeActionId, item => item.Order));

            return(RedirectToAction("EditRecipe",
                                    new { id = recipe.Id, statusMessage = "Recipe Action group order updated" }));
        }