public async Task <IActionResult> New(PostAddDto postAddDto) { if (!ModelState.IsValid) { return(View(postAddDto)); } await _postService.AddAsync(postAddDto); return(RedirectToAction(nameof(Index))); }
public async Task <IResult> AddAsync(PostAddDto postAddDto, string createdByName, int userId) { var post = Mapper.Map <Post>(postAddDto); post.CreatedByName = createdByName; post.ModifiedByName = createdByName; post.UserId = userId; await UnitOfWork.Posts.AddAsync(post); await UnitOfWork.SaveAsync(); return(new Result(ResultStatus.Success, Messages.Post.Add(post.Title))); }