Beispiel #1
0
        public ActionResult Create(Topic topic)
        {
            topic.CreatedBy = db.Users.First();

            if (ModelState.IsValid)
            {
                db.Topics.Add(topic);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(topic);
        }
Beispiel #2
0
 public ActionResult Edit(Topic topic)
 {
     if (ModelState.IsValid)
     {
         db.Entry(topic).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CreatedById = new SelectList(db.Users, "UserId", "Name", topic.CreatedById);
     return View(topic);
 }