Exemplo n.º 1
0
        public async Task <UserProfileResponse> GetById(int?id)
        {
            if (id.IsNotPositiveInt())
            {
                _logger.Warning(NullInput, nameof(id));
                return(new UserProfileResponse(HttpBadRequest, BadRequestMsg));
            }

            try
            {
                Debug.Assert(id != null, nameof(id) + " != null");
                var user = await _profileDataService.GetById(id.Value);

                if (user == null)
                {
                    _logger.Error(FailedToGetId, nameof(UserProfile), id);
                    return(new UserProfileResponse(HttpBadRequest, BadRequestMsg));
                }
                return(new UserProfileResponse(HttpOk, user));
            }
            catch (Exception e)
            {
                _logger.Error(e, FailedToGetId, nameof(UserProfile), id);
                return(new UserProfileResponse(HttpInternalServerError, InternalServerErrorMsg));
            }
        }
 public HttpResponseMessage GetById(int Id)
 {
     try
     {
         ItemResponse <ProfileDataViewModel> resp = new ItemResponse <ProfileDataViewModel>();
         resp.Item = _profileDataService.GetById(Id);
         log.Info("ProfileData GetById Successful");
         return(Request.CreateResponse(HttpStatusCode.OK, resp));
     }
     catch (Exception ex)
     {
         log.Error("ProfileData GetById Error", ex);
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }