public IHttpActionResult Post(RbSeasonStatCreate season) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } RbSeasonStatService service = new RbSeasonStatService(); if (!service.RbCreateSeason(season)) { return(InternalServerError()); } return(Ok()); }
//CREATE public bool RbCreateSeason(RbSeasonStatCreate season) { var playerSeason = new SeasonStatRb() { PlayerId = season.PlayerId, Year = season.Year, RushingYards = season.RushingYards, RushingAttempts = season.RushingAttempts, ReceivingYards = season.ReceivingYards, Receptions = season.Receptions, RushingTouchdowns = season.RushingTouchdowns, ReceivingTouchdowns = season.ReceivingTouchdowns, Fumbles = season.Fumbles, PlayerNumber = season.PlayerNumber, Team = season.Team }; using (var ctx = new ApplicationDbContext()) { ctx.RbSeasonStats.Add(playerSeason); return(ctx.SaveChanges() == 1); } }