public string AddKeyword(AddKeywordViewModel model) { var result = _commandDispatcher.Dispatch(new AddKeywordCommand() { Name = model.Name }); return(JsonConvert.SerializeObject(result)); }
public IActionResult Add(AddKeywordViewModel model) { if (ModelState.IsValid) { var result = _commandDispatcher.Dispatch(new AddKeywordCommand() { Name = model.Name }); if (result.IsSuccess) { return(RedirectToAction(nameof(List))); } if (result.Message != null) { ModelState.AddModelError("", result.Message); } foreach (var item in result.Errors) { ModelState.AddModelError("", item); } } return(View()); }