//UPDATE public bool UpdateRbSeasonStats(RbSeasonStatEdit season) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .RbSeasonStats .Single(s => s.RbSeasonId == season.RbSeasonId && s.IsDeleted == false); entity.PlayerId = season.PlayerId; entity.Year = season.Year; entity.RushingYards = season.RushingYards; entity.RushingAttempts = season.RushingAttempts; entity.ReceivingYards = season.ReceivingYards; entity.Receptions = season.Receptions; entity.RushingTouchdowns = season.RushingTouchdowns; entity.ReceivingTouchdowns = season.ReceivingTouchdowns; entity.Fumbles = season.Fumbles; entity.PlayerNumber = season.PlayerNumber; entity.Team = season.Team; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(RbSeasonStatEdit season) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } RbSeasonStatService service = new RbSeasonStatService(); if (!service.UpdateRbSeasonStats(season)) { return(InternalServerError()); } return(Ok()); }