public IActionResult AddAthlete(Athlete athlete) { if (ModelState.IsValid) { _context.AddAthlete(athlete); _context.SaveAthlete(); return(Ok(athlete.AthleteId)); } else { return(BadRequest()); } }
public async Task <IActionResult> DeleteAthlete([FromQuery] int athlete) { var response = new SingleModelResponse <Athlete>() as ISingleModelResponse <Athlete>; try { if (athlete.ToString() == null) { throw new Exception("Model is missing"); } response.Model = await Task.Run(() => { _context.DeleteAthlete(athlete); _context.SaveAthlete(); Athlete at = new Athlete { AthleteId = athlete }; return(at); }); } catch (Exception ex) { response.DidError = true; response.ErrorMessage = ex.Message; } return(response.ToHttpResponse()); }