예제 #1
0
        public async Task <ProfileReturnDto> GetUserProfileInfo(string userNickname)
        {
            if (userNickname == null)
            {
                return(await GetUserProfileInfo());

                //throw new ArgumentException();
            }

            var userId = long.Parse(_httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value);

            //var isOnline = await _connectionMapping.IsOnline(userId);
            var user =
                await(await _personService.GetAllAsync(o => o.UserName == userNickname)).FirstAsync();

            if (user == null)
            {
                throw new ObjectNotFoundException("User not found.");
            }

            var isOnline = await _connectionMapping.IsOnline(user.Id);

            return(user.Id == userId?user.ToProfileOwnReturnDto(isOnline) : user.ToProfileReturnDto(isOnline));

            //return user.Id == userId ? user.ToProfileOwnReturnDto() : user.ToProfileReturnDto();
        }