public IHttpActionResult Post(GameSystemCreate gameSystem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var gsService = CreateGameSystemService(); if (!gsService.CreateGameSystem(gameSystem)) { return(InternalServerError()); } return(Ok()); }
public bool CreateGameSystem(GameSystemCreate model) { var entity = new GameSystem() { GameSystemName = model.GameSystemName, GameForSystem = model.GameForSystem, GameSystemPrice = model.GameSystemPrice //entity and add it to the database table. }; using (var ctx = new ApplicationDbContext()) { ctx.GameSystems.Add(entity); return(ctx.SaveChanges() == 1); } }