public async Task <ActionResult <RiderDto[]> > Update([FromBody] RiderDto category) { if (category == null) { return(BadRequest("Category not set")); } var entity = await dataContext.Riders.FindAsync(category.Id); if (entity == null) { return(NotFound()); } var raceId = entity.RaceId; category.UpdateEntity(entity, dataContext); dataContext.Riders.Update(entity); await dataContext.SaveChangesAsync(); return(await Get(raceId)); }
public async Task <ActionResult <RiderDto[]> > Add(int id, [FromBody] RiderDto rider) { if (rider == null) { return(BadRequest("Category not posted")); } var race = await dataContext.Races.FindAsync(id); if (race == null) { return(NotFound()); } var entity = rider.UpdateEntity( new Rider { Race = race, RaceId = race.Id }, dataContext ); dataContext.Riders.Add(entity); await dataContext.SaveChangesAsync(); return(await Get(id)); }