コード例 #1
0
        public ActionResult Create(UserComment usercomment)
        {
            if (ModelState.IsValid)
            {
                _db.UserComments.Add(usercomment);
                _db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.AuthorID = new SelectList(_db.Users, "UserId", "UserName", usercomment.AuthorID);
            ViewBag.ReceiverID = new SelectList(_db.Users, "UserId", "UserName", usercomment.ReceiverID);
            return View(usercomment);
        }
コード例 #2
0
 public ActionResult Edit(UserComment usercomment)
 {
     if (usercomment.AuthorID != (Guid)Membership.GetUser().ProviderUserKey) { return HttpNotFound(); }
     if (ModelState.IsValid)
     {
         _db.Entry(usercomment).State = EntityState.Modified;
         _db.SaveChanges();
         return RedirectToAction("Index");
     }
     return HttpNotFound();
 }