public ActionResult Create(FormCollection collection) { try { using (var db = new DocumentDataContext()) { Comment comment = new Comment { DocumentId = int.Parse(collection["DocumentId"]), CreatedAt = DateTime.Now, Description = collection["Description"], UserId = db.getUserIdForUserName(User.Identity.Name) }; db.insertComment(comment); } return RedirectToAction("Details", "Document", new { id = collection["DocumentId"]}); } catch { return View(); } }
private void detach_Comments(Comment entity) { this.SendPropertyChanging(); entity.User = null; }
private void attach_Comments(Comment entity) { this.SendPropertyChanging(); entity.User = this; }
partial void DeleteComment(Comment instance);
partial void UpdateComment(Comment instance);
partial void InsertComment(Comment instance);
/*public Document getDocument(int id) { var dcouments = from d in this.Documents where d.Id == id select d; return dcouments.First(); }*/ public void insertComment(Comment comment) { this.Comments.InsertOnSubmit(comment); this.SubmitChanges(); }