示例#1
0
 public static GetUserThreadsInfoDto Map(this UserThreadsInfoRequest request, string username) =>
 new GetUserThreadsInfoDto
 {
     Size       = request.Size.Value,
     StartIndex = request.StartIndex.Value,
     Username   = username
 };
        public async Task <IActionResult> GetCurrentThreads([FromQuery, Required] UserThreadsInfoRequest request)
        {
            _logger.LogInformation($"Getting threads info for user with username - {User.Identity.Name}");

            var usersInfoResult = await _userInfoService.GetUserThreadsInfo(request.Map(User.Identity.Name));

            if (usersInfoResult.IsSuccess)
            {
                _logger.LogInformation($"Successful threads info retrieval for user with username - {User.Identity.Name}");

                return(Ok(new UserThreadsInfoResult(usersInfoResult.Value)));
            }

            var statusCodeResult = GetErrorResult(usersInfoResult.ErrorType);

            _logger.LogWarning(statusCodeResult.StatusCode.HasValue
                ? $"Failed threads info retrieval for user with username - {User.Identity.Name}; Status code - {statusCodeResult.StatusCode.Value}, reason - {statusCodeResult.Value}"
                : $"Failed threads info retrieval for user with username - {User.Identity.Name}; Reason - {statusCodeResult.Value}");

            return(statusCodeResult);
        }