public ActionResult AddComment(CommentModel model) { if((!AuthProvider.IsAuthorized)&&model.Name.IsNullOrWhiteSpace()) throw new Exception("Не удалось добавить комментарий"); using (var db=new DatabaseModel()) { db.comment.Add(new comment { ClientId = AuthProvider.IsAuthorized ? (int?) AuthProvider.ClientId : null, Name = model.Name, Text = model.Message }); db.SaveChanges(); } return new JsonResult{Data = true, JsonRequestBehavior = JsonRequestBehavior.DenyGet}; }
public ActionResult _CommentAddingPartial() { CommentModel model=new CommentModel(); return PartialView("Partial/_CommentAddingPartial",model); }