public async Task <AppUserDetail> GetUserDetails(Guid userId) { var appUserTask = _userRepository.FindByIdAsync(userId); var addressTask = _addressRepository.GetAsync(userId); var emalTask = _userEmailsRepository.GetUserEmailAsync(userId); var phoneTask = _userPhonesRepository.GetUserPhoneDetailByUserId(userId); var detailTask = _userDetailRepository.GetUserDetailByUserId(userId); var taskResult = Task.WhenAll(appUserTask, addressTask, emalTask, phoneTask, detailTask); try { await taskResult.ConfigureAwait(false); if (taskResult.IsCompletedSuccessfully) { return(new AppUserDetail { ApplicationUser = _mapper.Map <AppUserDto>(await appUserTask), CurrentAddress = _mapper.Map <AddressDto>(await addressTask), UserDetails = _mapper.Map <UserDetailDto>(await detailTask), Email = _mapper.Map <EmailDto>(await emalTask), Phone = _mapper.Map <PhoneDto>(await phoneTask) }); } } catch (Exception ex) { throw ex; } return(null); }
/// <summary> /// Finds the by user name. /// </summary> /// <param name="userName">user name</param> /// <returns> /// User data object /// </returns> public async Task <IUser> FindByUserName(string userName) { var userObj = await FindSingleAsync("SELECT * FROM Users WHERE UserName=@UserName", new { UserName = userName }).ConfigureAwait(false); if (userObj.IsNotNull()) { var emailObj = await _userEmailsRepository.GetUserEmailAsync(userObj.Id).ConfigureAwait(false); if (emailObj.IsNotNull()) { userObj.Email = emailObj.Email; } } return(userObj); }