public async Task <IActionResult> Create(NewPostViewModel newPostViewModel) { #region CREATING A NEW POST var userId = _userManager.GetUserId(User); var user = _userManager.FindByIdAsync(userId).Result; var post = _postBLL.BuildPost(newPostViewModel, user); await _postService.Add(post); #endregion #region INCREASING THE TOTAL POST AMOUNT IN FORUM var forum = _forumService.GetById(newPostViewModel.ForumId); forum.AmountTotalPost += 1; #endregion #region INSERTING NEW FORUM AMOUNT bool userFirstPostByForum = _forumService.CheckUserFirstPostByForum(userId.ToString(), newPostViewModel.ForumId); //If it is the first time that the user is creating a post related with the forum, then increase one user of the forum bcz a new user has just used the forum for the first time. if (userFirstPostByForum == true) { var model = _forumBLL.GetForumUserNewAmount(user, forum); await _forumService.AddNewUser(model); } #endregion await _forumService.Update(forum); return(RedirectToAction("Index", "Post", new { id = post.Id })); }