Beispiel #1
0
        public async Task<IActionResult> Create(CreateMenuViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var createMenuCommand = new CreateMenuCommand
                {
                    Name = viewModel.Name,
                    Title = viewModel.Title
                };

                var result = await _menuService.CreateMenuAsync(createMenuCommand);
                if (result.Success)
                {
                    return RedirectToAction(nameof(Index));
                }
                
                ModelState.AddCommandErrors(result);
            }
            
            return View(viewModel);
        }
Beispiel #2
0
 public async Task<CommandResult> CreateMenuAsync(CreateMenuCommand command)
 {
     return await _commandBus.ExecuteAsync(command);
 }