示例#1
0
        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));
        }
        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);
            }
        }