Exemplo n.º 1
0
        public async Task <IActionResult> GetUserAsync(int id)
        {
            if (id == 0)
            {
                return(BadRequest("A valid Id is required"));
            }

            try
            {
                var response = await _applicationService.GetAsync(id);

                var webResponse = new GetWebResponse <UserDto>()
                                  .From(response);

                if (webResponse.IsSuccessful)
                {
                    return(Ok(webResponse));
                }

                return(BadRequest(webResponse.Errors));
            }
            catch (Exception ex)
            {
                var message = "Unable to retrieve user";
                Console.WriteLine(ex);
                _logManager.LogError(ex, message);
                return(BadRequest(message));
            }
        }
Exemplo n.º 2
0
 public async Task <IActionResult> GetAsync(long id)
 {
     return(await _userApplicationService.GetAsync(id).ResultAsync());
 }
Exemplo n.º 3
0
 public async Task <IActionResult> GetProfile()
 {
     return(Result(await _userApplicationService.GetAsync(UserModel.Id)));
 }