public FullUserDTO fullUser(string username) { var user = _userRepository.GetSingle(x => x.Username == username); FullUserDTO fullUser = _mapper.Map <FullUserDTO>(user); return(fullUser); }
public async Task <FullUserDTO> GetfullUser(int id) { try { var fullUser = await _repo.GetFullUser(id); var fullUserDto = new FullUserDTO { ID = id, Firstname = fullUser.Firstname, Lastname = fullUser.Lastname, DateOfBirth = fullUser.DateOfBirth.Date, Gender = fullUser.Gender, IdentificationNumber = fullUser.IdentificationNumber, CityID = fullUser.CityID, RelativePath = fullUser.PictureRelativePath, RelatedUsers = new List <RelatedUserDto>(), Phones = new List <PhoneDTO>() }; if (fullUser.ContactPersons != null) { foreach (var item in fullUser.ContactPersons) { fullUserDto.RelatedUsers.Add(new RelatedUserDto { RelatedUserId = item.RelatedUserID, RelationType = item.RelationType }); } } if (fullUser.Phones != null) { foreach (var item in fullUser.Phones) { fullUserDto.Phones.Add(new PhoneDTO { Type = item.Type, Number = item.Number }); } } if (!string.IsNullOrEmpty(fullUser.PictureRelativePath)) { fullUserDto.ImageBase64 = _imgHelper.GetImageFromDisk(fullUser.PictureRelativePath); } return(fullUserDto); } catch (Exception e) { _logger.LogException(e); throw e; } }