public IHttpActionResult AddRoom(GameRoom room)
 {
     try
     {
        if (ServerContext.Instance.roomServices.addRoom(room) == false)
           return BadRequest();
        return Ok();
     }
     catch (Exception e)
     {
         return BadRequest();
     }
 }
 public bool registerUserRoom(UserGameRoom ugr)
 {
     try
     {
         user = new User() { Username = ugr.user.Username, Id = ugr.user.Id, Role = ugr.user.Role };
         gameRoom = new GameRoom() {Id = ugr.gameRoom.Id, Date = ugr.gameRoom.Date, Name = ugr.gameRoom.Name, PainterId = ugr.gameRoom.PainterId, Users = ugr.gameRoom.Users };
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
 public bool addNewPlayer(User user, GameRoom gameroom)
 {
     try
     {
         foreach (var gr in gameRooms)
             if (gr.Id == gameroom.Id)
             {
                 gr.Users.Add(user);
                 break;
             }
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
 public bool addRoom(GameRoom room)
 {
     try
     {
         if (getRoom(room.Id) != null)
             return false;
         else
         {
             ServerContext.Instance.databaseContext.GameRooms.Add(room);
             ServerContext.Instance.databaseContext.SaveChanges();
             return true;
         }
     }
     catch (Exception e)
     {
         return false;
     }
 }
 public bool addRoom(GameRoom room)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         try
         {
             if (getRoom(room.Id) != null)
                 return false;
             else
             {
                 db.GameRooms.Add(room);
                 db.SaveChanges();
                 return true;
             }
         }
         catch (Exception e)
         {
             return false;
         }
     }
 }
        public bool addNewRoom(string name, User user)
        {
            try
            {
                GameRoom gr = new GameRoom() { Id = idGenerator.Next(), Name = name, Date = DateTime.Now, PainterId = user.Id };
                gr.Users = new List<User>();
                gr.Users.Add(user);

                gameRooms.Add(gr);

                return true;
            }
            catch(Exception e)
            {
                return false;
            }
        }
 public bool getIntoRoom(GameRoom room)
 {
     return ServerContext.Instance.addNewPlayer(user, room);
 }
 public bool makeNewRoom(GameRoom newgr)
 {
     return ServerContext.Instance.addNewRoom(newgr.Name, user);
 }