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()); }
public IActionResult DeleteAthlete(int athleteId) { if (ModelState.IsValid) { Athlete athlete = _context.GetAthlete(athleteId); if (athlete == null) { return(NotFound()); } _context.DeleteAthlete(athlete); _context.SaveAthlete(); return(Ok()); } else { return(BadRequest(ModelState)); } }