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