public IHttpActionResult CreateGameSet(CreateGameSetViewModel viewModel) { try { GameSetViewModel gameSetViewModel = GamesService.CreateGameSet(viewModel); return(Content(HttpStatusCode.Created, gameSetViewModel)); } catch (NotFoundEntityException ex) { return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public static GameSetViewModel CreateGameSet(CreateGameSetViewModel viewModel) { GamesCycle gamesCycle = _gamesRepo.GetGameCycleById(viewModel.GameCycleId); if (gamesCycle == null) { throw new NotFoundEntityException("Game cycle with this Id doesn't exist"); } if (!gamesCycle.IsPublished) { throw new NotFoundEntityException("Game cycle with this Id doesn't published"); } GameSet gameSet = new GameSet(); gameSet.InjectFrom(viewModel); _gamesRepo.AddGameSet(gameSet); GameSetViewModel gameSetViewModel = new GameSetViewModel(); gameSetViewModel.InjectFrom(gameSet); return(gameSetViewModel); }