Пример #1
0
 public IActionResult UpdateAthlete(Athlete athlete)
 {
     if (ModelState.IsValid)
     {
         _context.UpdateAthlete(athlete);
         _context.SaveAthlete();
         return(Ok(athlete.AthleteId));
     }
     else
     {
         return(BadRequest());
     }
 }
Пример #2
0
        public async Task <IActionResult> UpdateAthlete([FromBody] Athlete athlete)
        {
            var response = new SingleModelResponse <Athlete>()
                           as ISingleModelResponse <Athlete>;

            try
            {
                if (athlete == null)
                {
                    throw new Exception("Model is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    return(_context.UpdateAthlete(athlete));
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }