public ActionResult PostingComment(int id, string commentContents, string userName) { if (commentContents.IsNullOrWhiteSpace()) { return(RedirectToAction("WallPost")); } //Create new object of Post - new Post var newComment = new Comment { CommentContent = commentContents, CommentDateTime = DateTime.Now, ApplicationUser = _repo.GetUser(User.Identity.Name), PostId = id, }; //Add new Post to database _repo.AddNewComment(newComment); //Save changes in database _repo.SaveChanges(); var newCommentNotification = new Notification { NotificationTitle = "Skomentowany wpis!", NotificationContent = "Twój wpis skomentował użytkownik:" + User.Identity.Name, NotificationDateTime = DateTime.Now, Post = _repo.GetPostById(id), ApplicationUser = _repo.GetUser(userName) }; //Add new Notification to database _repo.AddNewNotification(newCommentNotification); //Save changes in database _repo.SaveChanges(); return(RedirectToAction("WallPost")); }