public bool CreateCardGame(CardGameCreate model) { var entity = new CardGame() { GameName = model.GameName, Genre = model.Genre, AgeRating = model.AgeRating, MaxNumberOfPlayers = model.MaxNumberOfPlayers, MinNumberOfPlayers = model.MinNumberOfPlayers, TeamGame = model.TeamGame, StorageId = model.StorageId, NumberOfCards = model.NumberOfCards, ExtraEquipmentUsed = model.ExtraEquipmentUsed, IsGamblingGame = model.IsGamblingGame, AvgPlayTimeInMin = model.AvgPlayTimeInMin, PublishYear = model.PublishYear }; using (var ctx = new ApplicationDbContext()) { ctx.CardGames.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(CardGameCreate cardGame) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCardGameService(); if (!service.CreateCardGame(cardGame)) { return(InternalServerError()); } return(Ok()); }