Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 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));
     }
 }