public ActionResult Create(Reply reply, int topicId) { reply.Topic = db.Topics.Find(topicId); reply.CreatedBy = db.Users.First(); if (ModelState.IsValid) { db.Replies.Add(reply); db.SaveChanges(); return RedirectToAction("Details", "Topic", new {id=topicId}); } return View(reply); }
public ActionResult Edit(Reply reply) { if (ModelState.IsValid) { db.Entry(reply).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CreatedById = new SelectList(db.Users, "UserId", "Name", reply.CreatedById); return View(reply); }