Exemplo n.º 1
0
        public async Task <IActionResult> GetAllListingsForUser()
        {
            try
            {
                var id   = HttpContext.User.FindFirst(ClaimTypes.Email).Value;
                var user = await _userManager.FindByEmailAsync(id);

                var allListings = await _listingCommand.GetAllListingsForUserCommand(user.Id);

                var profile = await _userCommand.GetUserProfile(user);

                var reviews = await _userCommand.GetUserReviews(user.Id);

                var response = new GetProfileForUserSettingsResponse()
                {
                    UserListingCollectionDto = allListings,
                    UserProfileDto           = profile,
                    UserProfileReviewList    = reviews
                };

                return(Ok(response));
            }
            catch (Exception ex)
            {
                _logger.LogError($"error while getting profile for user: {ex}");
                return(StatusCode((int)HttpStatusCode.InternalServerError, "error while getting profile for user"));
            }
        }