public IHttpActionResult Put(TeSeasonStatEdit season) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TeSeasonStatService service = new TeSeasonStatService(); if (!service.UpdateTeSeasonStats(season)) { return(InternalServerError()); } return(Ok()); }
//UPDATE public bool UpdateTeSeasonStats(TeSeasonStatEdit season) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .TeSeasonStats .Single(s => s.TeSeasonId == season.TeSeasonId && s.IsDeleted == false); entity.PlayerId = season.PlayerId; entity.Year = season.Year; entity.Receptions = season.Receptions; entity.Targets = season.Targets; entity.Drops = season.Drops; entity.ReceivingYards = season.ReceivingYards; entity.YardsAfterCatch = season.YardsAfterCatch; entity.Touchdowns = season.Touchdowns; entity.PlayerNumber = season.PlayerNumber; entity.Team = season.Team; return(ctx.SaveChanges() == 1); } }