Пример #1
0
        public IActionResult PutGame([FromRoute] int gameid, [FromRoute] int userid, [FromBody] GameByUser GameByUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (gameid != GameByUser.GameId || userid != GameByUser.UserId)
            {
                return(BadRequest());
            }
            GameByUser.GameId = gameid;
            GameByUser.UserId = userid;

            bool test = true;

            try
            {
                test = unit.GameByUserManager.Update(GameByUser);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (test == false)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public IActionResult PostPlace([FromRoute] int gameid, [FromRoute] int userid, [FromBody] GameByUser GameByUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            GameByUser.UserId = userid;
            GameByUser.GameId = gameid;
            GameByUser g = unit.GameByUserManager.Insert(GameByUser);

            return(Created("GetGameInPlace", g));
        }