コード例 #1
0
        public async Task <IActionResult> GetClubMember([FromQuery] int athleteId)
        {
            var response = new SingleModelResponse <ClubMember>()
                           as ISingleModelResponse <ClubMember>;

            try
            {
                if (athleteId < 1)
                {
                    throw new Exception("Model is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    ClubMember member = _context.GetMemberByID(athleteId);
                    if (member == null)
                    {
                        throw new Exception("Club Member does not Exist");
                    }
                    return(member);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
コード例 #2
0
 public IActionResult GetClubMember(int memberId)
 {
     if (ModelState.IsValid)
     {
         ClubMember club = _memberRepo.GetMemberByID(memberId);
         if (club == null)
         {
             return(NotFound());
         }
         return(Json(club));
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }