コード例 #1
0
 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();
     }
 }
コード例 #2
0
 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();
     }
 }