Esempio n. 1
0
 public List <PhotoDTO> SearchPhotosExtended(
     string title,
     string takenDate,
     string place,
     string camera,
     string focalLength,
     string aperture,
     string cameraLockSpeed,
     string iso,
     string usedFlash
     )
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         DateTime td = DateTime.MinValue;
         if (!string.IsNullOrEmpty(takenDate))
         {
             //TODO not working
             DateTime.TryParse(takenDate, out td);
         }
         IEnumerable <Photo> photos = unitOfWork.Photos.SearchPhotosExtended(
             title,
             td,
             place,
             camera,
             focalLength,
             aperture,
             cameraLockSpeed,
             iso,
             usedFlash,
             WebSecurityService.GetCurrentUser().UserId);
         return(Mapper.Map <List <Photo>, List <PhotoDTO> >(photos.ToList()));
     }
 }
Esempio n. 2
0
 public static int GetAlbumsNumberForCurrentUser()
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         return(unitOfWork.Albums.GetAlbumsByUser(WebSecurityService.GetCurrentUser()).Count);
     }
 }
Esempio n. 3
0
 public void CreateComment(PhotoCommentDTO photoCommentDto)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         PhotoComment photoComment = Mapper.Map <PhotoComment>(photoCommentDto);
         photoComment.Created = DateTime.Now;
         photoComment.UserId  = WebSecurityService.GetCurrentUser().UserId;
         unitOfWork.PhotoComments.Add(photoComment);
         unitOfWork.Complete();
     }
 }
Esempio n. 4
0
 public void CreateAlbum(AlbumDTO albumDto)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         Album album = Mapper.Map <Album>(albumDto);
         album.UserId    = WebSecurityService.GetCurrentUser().UserId;
         album.TitleSlug = album.Title.Unidecode().GenerateSlug();
         unitOfWork.Albums.Add(album);
         unitOfWork.Complete();
     }
 }
Esempio n. 5
0
 public List <AlbumDTO> GetAllAlbums()
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         IEnumerable <Album> albums = unitOfWork.Albums.GetAlbumsByUser(WebSecurityService.GetCurrentUser());
         foreach (Album album in albums)
         {
             UpdateAlbumCover(unitOfWork, album);
         }
         return(Mapper.Map <IEnumerable <Album>, List <AlbumDTO> >(albums));
     }
 }
Esempio n. 6
0
 public List <PhotoDTO> SearchPhotos(string photoSearchText)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         List <Photo> photos = unitOfWork.Photos.SearchPhotos(photoSearchText, WebSecurityService.GetCurrentUser().UserId);
         return(Mapper.Map <List <Photo>, List <PhotoDTO> >(photos));
     }
 }