コード例 #1
0
ファイル: UsersController.cs プロジェクト: michalShawat/ex3
        public IHttpActionResult PutUser(string id, User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public MazePositions PostMaze(BoolHelper newMaze)
        {
            if (newMaze.isNewMaze)
            {
                _context.BlockPositions.RemoveRange(_context.BlockPositions);

                MazePositions cont = new MazePositions();
                MazeGenerator gen  = new MazeGenerator();
                cont.maze = gen.generateMaze();
                foreach (BlockPosition block in cont.maze)
                {
                    _context.BlockPositions.Add(block);
                }

                _context.SaveChanges();
                return(cont);
            }
            else
            {
                MazePositions cont = new MazePositions
                {
                    maze = new System.Collections.Generic.List <BlockPosition>()
                };
                cont.maze = _context.BlockPositions.ToList();

                return(cont);
            }
        }