public async Task <bool> UpdateTeam(RacingEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Racings.Single(r => r.Id == model.Id); entity.BasedOutOF = model.BasedOutOF; entity.Drivers = model.Drivers; entity.RaceEvent = model.RaceEvent; entity.TeamName = model.TeamName; return(await ctx.SaveChangesAsync() == 1); } }
public async Task <IHttpActionResult> UpdateTeams([FromUri] int id, [FromBody] RacingEdit model) { if (ModelState.IsValid) { Racing racing = await _content.Racings.FindAsync(id); var service = CreateRaceService(); if (racing != null) { await service.UpdateTeam(model); return(Ok(model)); } } return(BadRequest()); }