Beispiel #1
0
        public JsonResult PutUser(int id, User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.User_ID)
            {
                return(BadRequest());
            }

            db.Entry(user).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "Game_ID,Game_Name,Max_Player_Count")] Game game)
        {
            if (ModelState.IsValid)
            {
                db.Games.Add(game);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(game));
        }
        public ActionResult Create([Bind(Include = "Id,Game_Session_ID,Users_ID")] Session_Users session_Users)
        {
            if (ModelState.IsValid)
            {
                db.Session_Users.Add(session_Users);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Game_Session_ID = new SelectList(db.Game_Sessions, "Game_Session_ID", "Game_Session_ID", session_Users.Game_Session_ID);
            ViewBag.Users_ID        = new SelectList(db.Users, "User_ID", "User_Name", session_Users.Users_ID);
            return(View(session_Users));
        }