コード例 #1
0
        public IActionResult Edit(PostEditVm postVm)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                _postService.UpdatePost(postVm);
                return(RedirectToAction("Index"));
            }
            catch (BusinessRoleException ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View());
            }
            catch (Exception ex)
            {
                ViewData["Erro"] = ex.Message;
                return(View("_Erro"));
            }
        }
コード例 #2
0
 public void UpdatePost(PostEditVm postVm)
 {
     this._repository.Update(mapper.Map <Post>(postVm));
 }