Example #1
0
        public async Task <UserPhotoResult> GetUserPhotoByCodeAsync(string code, UserPictureType typeId)
        {
            var picture = await _userPhotoRepository.GetUserPhotoByCodeAsync(code, typeId);

            picture.BinaryData = Convert.FromBase64String(picture.ImageData);
            return(picture);
        }
        public async Task <string> GetCodeByUserIdAsync(long userId, UserPictureType typeId)
        {
            var photoType     = (byte)typeId;
            var userPhotoCode = await _userPhotoRepository.Get(x => x.UserId == userId && x.TypeId.Equals(photoType))
                                .Select(x => x.Code).FirstOrDefaultAsync();

            return(userPhotoCode);
        }
Example #3
0
        private UserPhotoResult GetUserPhoto(long userId, UserPictureType type)
        {
            var userPhoto = _userPhotoService.GetUserPhotoByUserId(userId, type);

            if (userPhoto != null)
            {
                userPhoto.Url = userPhoto.Code;
            }

            return(userPhoto);
        }
        public async Task DeleteUserPhotoAsync(long userId, UserPictureType userPhotoType)
        {
            if (userId <= 0)
            {
                throw new ArgumentNullException(nameof(userId));
            }

            var type      = (byte)userPhotoType;
            var userPhoto = _userPhotoRepository
                            .Get(x => x.UserId.Equals(userId) && x.TypeId.Equals(type))
                            .FirstOrDefault();

            if (userPhoto == null)
            {
                return;
            }

            await _userPhotoRepository.DeleteAsync(userPhoto);
        }
        public UserPhotoResult GetUserPhotoByUserId(long userId, UserPictureType typeId)
        {
            var photoType  = (byte)typeId;
            var userPhotos = _userPhotoRepository.Get(x => x.UserId == userId && x.TypeId.Equals(photoType));

            if (userPhotos == null || !userPhotos.Any())
            {
                return(null);
            }

            return(userPhotos.Select(x => new UserPhotoResult()
            {
                Code = x.Code,
                Description = x.Description,
                Id = x.Id,
                Name = x.Name,
                Url = x.Url,
                TypeId = x.TypeId
            }).FirstOrDefault());
        }
        public async Task <UserPhotoResult> GetUserPhotoByCodeAsync(string code, UserPictureType type)
        {
            var photoType  = (byte)type;
            var userPhotos = await _userPhotoRepository.GetAsync(x => x.Code.Equals(code) && x.TypeId.Equals(photoType));

            if (userPhotos == null || !userPhotos.Any())
            {
                return(null);
            }

            return(userPhotos.Select(x => new UserPhotoResult()
            {
                Code = x.Code,
                Description = x.Description,
                Id = x.Id,
                ImageData = x.ImageData,
                Name = x.Name,
                TypeId = x.TypeId,
                UserId = x.UserId,
                Url = x.Url
            }).FirstOrDefault());
        }
        public async Task <IList <UserPhotoResult> > GetUserPhotosByUserIdsAsync(IEnumerable <long> userIds, UserPictureType typeId)
        {
            var photoType      = (byte)typeId;
            var userPhotoCodes = await _userPhotoRepository.Get(x => x.UserId.In(userIds) && x.TypeId.Equals(photoType))
                                 .Select(x => new UserPhotoResult
            {
                Code   = x.Code,
                UserId = x.UserId
            }).ToListAsync();

            return(userPhotoCodes);
        }
        public async Task <IList <UserPhotoResult> > GetUserPhotoByUserIdsAsync(IEnumerable <long> userIds, UserPictureType userPictureType)
        {
            var photoType = (byte)userPictureType;

            return(await _userPhotoRepository.Table.Select(x => new UserPhotoResult()
            {
                Code = x.Code,
                Description = x.Description,
                Id = x.Id,
                Name = x.Name,
                Url = x.Url,
                TypeId = x.TypeId,
                UserId = x.UserId
            }).Where(x => x.UserId.In(userIds) && x.TypeId.Equals(photoType)).ToListAsync());
        }
Example #9
0
 public async Task <IList <UserPhotoResult> > GetUserPhotoByUserIdsAsync(IEnumerable <long> userIds, UserPictureType typeId)
 {
     return(await _userPhotoRepository.GetUserPhotoByUserIdsAsync(userIds, typeId));
 }
Example #10
0
 public UserPhotoResult GetUserPhotoByUserId(long userId, UserPictureType typeId)
 {
     return(_userPhotoRepository.GetUserPhotoByUserId(userId, typeId));
 }
Example #11
0
 public async Task DeleteUserPhotoAsync(long userId, UserPictureType userPhotoType)
 {
     await _userPhotoRepository.DeleteUserPhotoAsync(userId, userPhotoType);
 }