public async Task <GetPhotoDto> GetPhotoDetailsDtoByPhotoId(int PhotoId)
 {
     return(await _userPhotoRepository
            .GetUserPhoto()
            .Select(photo => new GetPhotoDto
     {
         UserName = photo.User.Name,
         ImageBytes = photo.Photo.ImageBytes,
         Title = photo.Photo.Title,
         UploadDateTime = photo.Photo.UpdateDateTime
     })
            .FirstOrDefaultAsync(photo =>
                                 photo.UserPhotoId == PhotoId
                                 ));
 }
        public async Task <IList <GetPhotoDto> > GetListPhotosByUserId(int userId)
        {
            IList <GetPhotoDto> getPhotoDtos = new List <GetPhotoDto>();
            var userPhotos = await _photoRepository
                             .GetUserPhoto()
                             .Include(userphoto => userphoto.Photo)
                             .Include(userphoto => userphoto.User)
                             .OrderByDescending(photo => photo)
                             .Where(userPhoto => userPhoto.UserId == userId)
                             .ToListAsync();

            foreach (Entities.UserPhoto userPhoto in userPhotos)
            {
                var likesPhotoDtos = await _getLikesPhotoBusiness.GetLikesPhotoDtosByUserPhotoId(userPhoto.Id);

                getPhotoDtos.Add(new GetPhotoDto
                {
                    UserPhotoId    = userPhoto.Id,
                    UserName       = userPhoto.User.Name,
                    ImageBytes     = userPhoto.Photo.ImageBytes,
                    Title          = userPhoto.Photo.Title,
                    UploadDateTime = userPhoto.Photo.UpdateDateTime,
                    UserId         = userPhoto.UserId,
                    LikesPhotoDtos = likesPhotoDtos
                });
            }
            return(getPhotoDtos);
        }
 public Response <UserPhotoViewModel> GetUserPhoto(int userID, bool isMyProfile)
 {
     return(_userPhotoRepository.GetUserPhoto(userID, isMyProfile));
 }