public static int GetPhotosNumberForCurrentUser() { using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext())) { return(unitOfWork.Photos.GetPhotosByUserId(WebSecurityService.GetCurrentUserId()).Count); } }
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())); } }
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)); } }
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(); } }
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(); } }
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(); } }
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)); } }
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); } }
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)); } }