public IHttpActionResult Put(SeasonStatEdit season) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } SeasonStatService service = new SeasonStatService(); if (!service.UpdateSeasonStats(season)) { return(InternalServerError()); } return(Ok()); }
//UPDATE public bool UpdateSeasonStats(SeasonStatEdit season) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .SeasonStat .Single(s => s.SeasonId == season.SeasonId && s.IsDeleted == false); entity.PlayerId = season.PlayerId; entity.Year = season.Year; entity.PassingYards = season.PassingYards; entity.RushingYards = season.RushingYards; entity.Completions = season.Completions; entity.Attempts = season.Attempts; entity.PassingTouchdowns = season.PassingTouchdowns; entity.RushingTouchdowns = season.RushingTouchdowns; entity.Interceptions = season.Interceptions; entity.PlayerNumber = season.PlayerNumber; entity.Team = season.Team; return(ctx.SaveChanges() == 1); } }