public ActionResult Comments_Destroy([DataSourceRequest]DataSourceRequest request, Comment comment) { var comentDb = this.comments.AllWithDeleted().Where(x => x.Id == comment.Id).FirstOrDefault(); this.comments.Delete(comentDb); this.comments.SaveChanges(); return Json(new[] { comment }.ToDataSourceResult(request, ModelState)); }
public void Create(string text, string creatorUserName, int fieldId) { var user = this.users.All().Where(x => x.UserName == creatorUserName).FirstOrDefault(); var field = this.fields.All().Where(x => x.Id == fieldId).FirstOrDefault(); var comment = new Comment { Creator = user, Field = field, Text = text }; this.comments.Add(comment); this.fields.SaveChanges(); }