public IActionResult Post(PostViewModel postViewModel, int id) { var post = _postService.GetPost(id); postViewModel.post = post; if (!ModelState.IsValid) { postViewModel.Responses = _postService.GetResponses(post); return(View(postViewModel)); } var newResponse = new Response(); var user = _userService.GetUser(User.Identity.Name); newResponse.Content = postViewModel.Content; newResponse.Post = post; newResponse.User = user; newResponse = _responseService.AddResponseWithCommit(newResponse); _postService.AddResponse(post, newResponse); var newNotification = new Notification { NotifiedUser = post.User, NotifyingUser = user, NotificationType = NotificationType.Response, Post = post }; _notificationService.AddNotification(newNotification); _ccDbContextService.Commit(); postViewModel.Responses = _postService.GetResponses(post); // zeby nowa odpowiedz byla zawarta return(View(postViewModel)); }