public ActionResult Like(int ?id) { User u = new User(); int userid = Convert.ToInt32(Session["ID"]); u = db.User.Find(userid); Gab gab = db.Gab.Find(id); gab.likenumber++; gab.LikeUsers.Add(u); db.SaveChanges(); return RedirectToAction("MainPage"); }
public ActionResult Edit(User user) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("MainPage", "Gab"); }
public ActionResult Create(User user) { if (ModelState.IsValid) { Background b = new Background(); b = db.Background.Find(user.BackgroundID); user.Background = b; Avatar a = new Avatar(); a = db.Avatar.Find(user.AvatarID); user.Avatar = a; db.User.Add(user); db.SaveChanges(); Session["ID"] = user.U_ID; Session["username"] = user.Username; Session["Background"] = user.Background.BPath; Session["avatar"] = user.Avatar.APath; return RedirectToAction("MainPage","Gab"); } ViewBag.AvatarID = new SelectList(db.Avatar, "ID", "APath", user.AvatarID); ViewBag.BackgroundID = new SelectList(db.Background, "ID", "BPath", user.BackgroundID); return View(user); }