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(); } }
public ActionResult Create(FormCollection collection) { try { using (var db = new DocumentDataContext()) { Document document = new Document { Title = collection["Title"].ToString(), Description = collection["Description"].ToString(), CreatedAt = DateTime.Now, UserId = db.getUserIdForUserName(User.Identity.Name) }; db.Documents.InsertOnSubmit(document); db.SubmitChanges(); } return RedirectToAction("Index"); } catch { return View(); } }