public ActionResult Edit(Gab gab) { if (ModelState.IsValid) { db.Entry(gab).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(gab); }
public ActionResult Create(object sender, EventArgs e) { Gab gab = new Gab(); string content = Request.Form["content"]; gab.Date = DateTime.Now; gab.UserID = Convert.ToInt32(Session["ID"]); gab.User = db.User.Find(gab.UserID); gab.content = content; db.Gab.Add(gab); db.SaveChanges(); return RedirectToAction("MainPage"); }