Пример #1
0
 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");
 }
Пример #2
0
        public ActionResult Edit(User user)
        {

                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("MainPage", "Gab");
            
        }
Пример #3
0
 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);
 }