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); }
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(); }