public ActionResult Edit([Bind(Include = "IDboard,IDuser,IDgame,username,score")] LeaderBoard leaderBoard)
 {
     if (ModelState.IsValid)
     {
         db.Entry(leaderBoard).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IDgame = new SelectList(db.Game, "IDgame", "IDgame", leaderBoard.IDgame);
     ViewBag.IDuser = new SelectList(db.User, "IDuser", "username", leaderBoard.IDuser);
     return(View(leaderBoard));
 }
        // POST: SavedGames/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Create([Bind(Include = "IDSavedGame,IDGame,IDuser,score,datePlayed")] SavedGames savedGames)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.SavedGames.Add(savedGames);
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }

        //    ViewBag.IDGame = new SelectList(db.Game, "IDgame", "IDgame", savedGames.IDGame);
        //    ViewBag.IDuser = new SelectList(db.User, "IDuser", "username", savedGames.IDuser);
        //    return View(savedGames);
        //}

        // GET: SavedGames/Edit/5


        public ActionResult Edit(int?id, decimal score)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            SavedGames savedGames = db.SavedGames.Find(id);
            var        iduser     = savedGames.IDuser;

            if (savedGames == null)
            {
                return(HttpNotFound());
            }

            savedGames.score           = score;
            savedGames.datePlayed      = DateTime.Today.Date;
            db.Entry(savedGames).State = EntityState.Modified;
            db.SaveChanges();

            ViewBag.id = iduser;
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "IDgame,IDimg1,IDimg2,IDimg3,IDimg4,IDimg5,IDimg6,IDimg7")] Game game)
 {
     if (ModelState.IsValid)
     {
         db.Entry(game).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IDimg1 = new SelectList(db.Image.AsNoTracking(), "IDimage", "name", game.IDimg1);
     ViewBag.IDimg2 = new SelectList(db.Image.AsNoTracking(), "IDimage", "name", game.IDimg2);
     ViewBag.IDimg3 = new SelectList(db.Image.AsNoTracking(), "IDimage", "name", game.IDimg3);
     ViewBag.IDimg4 = new SelectList(db.Image.AsNoTracking(), "IDimage", "name", game.IDimg4);
     ViewBag.IDimg5 = new SelectList(db.Image.AsNoTracking(), "IDimage", "name", game.IDimg5);
     ViewBag.IDimg6 = new SelectList(db.Image.AsNoTracking(), "IDimage", "name", game.IDimg6);
     ViewBag.IDimg7 = new SelectList(db.Image.AsNoTracking(), "IDimage", "name", game.IDimg7);
     return(View(game));
 }
Exemplo n.º 4
0
        public ActionResult Save(HttpPostedFileBase upload)
        {
            var userId       = User.Identity.GetUserId();
            var userUserName = User.Identity.GetUserName();
            var id           = (db.User.Where(x => x.username == userUserName).First()).IDuser;
            var registered   = db.RegisteredUser.First(x => x.IDuser == id);

            if (upload != null && upload.ContentLength > 0)
            {
                using (var reader = new System.IO.BinaryReader(upload.InputStream))
                {
                    registered.avatar = reader.ReadBytes(upload.ContentLength);
                }

                db.Entry(registered).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(RedirectToAction("Index", "Manage"));
        }
Exemplo n.º 5
0
        public ActionResult Edit(HttpPostedFileBase upload, [Bind(Include = "IDimage,image,name,hint1,hint2,info,latitude,longitude")] Image image)
        {
            if (upload == null)
            {
                var images = (db.Image.AsNoTracking().Where(x => x.IDimage == image.IDimage));
                image.image = images.FirstOrDefault(x => x.IDimage == image.IDimage).image;
            }

            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    using (var reader = new System.IO.BinaryReader(upload.InputStream))
                    {
                        image.image = reader.ReadBytes(upload.ContentLength);
                    }
                }
                db.Entry(image).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(image));
        }