public ActionResult Create(string Content, int videoId) { if (User.Identity.IsAuthenticated == false) { return(Json(new { message = "redirect" }, JsonRequestBehavior.AllowGet)); } treca_aplikacija_model db = new treca_aplikacija_model(); comment comment = new comment(); comment.comment_video_id = (byte)videoId; string LoggedInUserName = User.Identity.GetApplicationUserUsername(); foreach (var x in db.users) { if (x.user_username.Equals(LoggedInUserName)) { comment.comment_user_id = x.users_id; } } comment.comment_created = DateTime.Now; comment.comment_content = Content; db.comments.Add(comment); db.SaveChanges(); //? UserViewModel CommentOwner = ApplicationUtils.CreateUserViewModelDTO(db.users.Find(comment.comment_user_id)); CommentViewModel Comment = ApplicationUtils.CreateCommentViewModelDTO(db.comments.Find(comment.comment_id)); return(Json(new { User = CommentOwner, Comment = Comment }, JsonRequestBehavior.AllowGet)); }