//[Authorize]
 public IHttpActionResult AddGame(Game game)
 {
     if(ModelState.IsValid)
     {
         _gameService.Add(game.Title, game.Genre, game.MaxPlayers, game.GamingSystems, User.Identity.Name);
         return Ok();
     }
     return BadRequest("This is a bad request");
 }
예제 #2
0
        public void Add(string title, string genra, int maxplayers, IList<GamingSystem> gamingSystems, string userName)
        {
            var user = _userRepo.FindByName(userName);

            var game = new Game()
            {
                User = user,
                Title = title,
                Genre = genra,
                MaxPlayers = maxplayers,
                GamingSystems = gamingSystems 
            };
        }                    
 public void AddGame(Game game)
 {
     _db.Games.Add(game);
     _db.SaveChanges();
 }