public async Task <IActionResult> GetUserHeader() { var userClaim = _httpContextAccessor.HttpContext.User.Identities.FirstOrDefault(); if (userClaim == null) { return(BadRequest(new Response <UserLoginDTO> { Error = true, ErrorDescription = "User not found.", StatusCode = StatusCodes.Status400BadRequest })); } UserHeadersDTO userHeader = new UserHeadersDTO(); try { int userid = Convert.ToInt32(userClaim.Name); int userPostCount = await _postService.GetUserPostCount(userid); userHeader = await _userService.GetUserHeader(userid); userHeader.PostCount = userPostCount; int userFollwerCount = await _follwerService.GetUserFollwerCount(userid); int userFollowingCount = await _follwerService.GetUserFollowingCount(userid); userHeader.FollowerCount = userFollwerCount; userHeader.FollowingCount = userFollowingCount; } catch (Exception ex) { return(BadRequest(new Response <UserLoginDTO> { Error = true, ErrorDescription = $"Internal server error. Error: {ex.Message}", StatusCode = StatusCodes.Status400BadRequest })); } return(Ok(new Response <UserHeadersDTO> { Error = false, ErrorDescription = null, ResponseModel = userHeader, StatusCode = StatusCodes.Status200OK })); }