예제 #1
0
        public string AddKeyword(AddKeywordViewModel model)
        {
            var result = _commandDispatcher.Dispatch(new AddKeywordCommand()
            {
                Name = model.Name
            });

            return(JsonConvert.SerializeObject(result));
        }
예제 #2
0
 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());
 }