Ejemplo n.º 1
0
 public async Task<CommandResult> EditMenuAsync(UpdateMenuDetailsCommand command)
 {
     return await _commandBus.ExecuteAsync(command);
 }
Ejemplo n.º 2
0
        public async Task<IActionResult> Edit(EditMenuViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var editMenuCommand = new UpdateMenuDetailsCommand
                {
                    Id = viewModel.Id,
                    Name = viewModel.Name,
                    Title = viewModel.Title
                };

                var result = await _menuService.EditMenuAsync(editMenuCommand);
                if (result.Success)
                {
                    return RedirectToAction(nameof(Index));
                }

                ModelState.AddCommandErrors(result);
            }

            return View(viewModel);
        }