Beispiel #1
0
 public static int GetPhotosNumberForCurrentUser()
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         return(unitOfWork.Photos.GetPhotosByUserId(WebSecurityService.GetCurrentUserId()).Count);
     }
 }
Beispiel #2
0
 public List <PhotoDTO> GetAllPhotos()
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         IEnumerable <Photo> photos = unitOfWork.Photos.GetPhotosByUserId(WebSecurityService.GetCurrentUserId());
         return(Mapper.Map <IEnumerable <Photo>, List <PhotoDTO> >(photos));
     }
 }
Beispiel #3
0
 public void CreatePhoto(PhotoDTO photoDto)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         Photo photo = Mapper.Map <Photo>(photoDto);
         photo.UserId = WebSecurityService.GetCurrentUserId();
         unitOfWork.Photos.Add(photo);
         unitOfWork.Complete();
     }
 }
Beispiel #4
0
 public int GetPhotosNumberForAlbum(Guid albumId, bool inAlbum)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         bool excludePrivate = true;
         int  userId         = unitOfWork.Albums.Get(albumId).UserId;
         if (WebSecurityService.IsAuthenticated)
         {
             excludePrivate = WebSecurityService.GetCurrentUserId() != userId;
         }
         return(unitOfWork.Photos.GetPhotosByUserAndAlbum(userId, albumId, inAlbum, excludePrivate).Count);
     }
 }