public void Test_Retrieves_Service_From_Locator()
        {
            Resolver.Register(() => Service, typeof(IPhotosService));
            var viewModel = new PhotoListViewModel(Router);

            viewModel.Service.Should().Be(Service);
        }
Example #2
0
        public PhotoList(string plotID)
        {
            InitializeComponent();
            _viewmodel = new PhotoListViewModel(Navigation, plotID);

            this.BindingContext = _viewmodel;
        }
Example #3
0
        public ActionResult PhotoList()
        {
            string             albumID = Request["albumID"];
            PhotoListViewModel model   = new PhotoListViewModel();

            model.SiteID          = BlogID;
            model.PhotoCollection = new List <Entity.blog_tb_Photo>();
            Entity.blog_tb_Album album = Utility.AlbumBll.GetEntity(albumID);
            model.Title = album.Display + "-" + base.Info.blogTitle;
            List <blog_tb_Photo> list = Utility.PhotoBll.Query(albumID);

            //是否远程IP地址  2015-6-16
            bool isRemote = Utility.IsRemote;

            foreach (var v in list)
            {
                Entity.blog_tb_Photo entity = new Entity.blog_tb_Photo();
                entity.ID      = v.ID;
                entity.Display = v.Display;
                if (String.IsNullOrEmpty(entity.Display))
                {
                    entity.Display = v.FileName;
                }

                string thumbUrl = v.ThumbUrl;
                if (isRemote)
                {
                    thumbUrl = Utility.ReplaceImgOrFileSrc(thumbUrl);
                }

                string url = v.Url;
                if (isRemote)
                {
                    url = Utility.ReplaceImgOrFileSrc(url);
                }

                entity.ThumbUrl = thumbUrl;
                if (String.IsNullOrEmpty(thumbUrl))
                {
                    entity.ThumbUrl = url;
                }
                model.PhotoCollection.Add(entity);
            }

            return(View("~/Views/Album/" + GetVersion() + "/PhotoList.cshtml", model));
        }
        public ActionResult ListPersonPhotos(int personId, int?photoId = null)
        {
            var person = DatabaseSession.Get <Person>(personId);

            if (photoId == null && person.Photo != null && !person.Photo.IsDefaultNoPic())
            {
                return(Redirect(this.GetURL(c => c.ListPersonPhotos(personId, person.Photo.PhotoId))));
            }

            var photos = DatabaseSession.Query <PersonPhoto>()
                         .Where(x => x.Person == person).Fetch(x => x.Photo)
                         .ToList();

            if (photoId == null && photos.Any())
            {
                return(Redirect(this.GetURL(c => c.ListPersonPhotos(personId, photos.First().Photo.PhotoId))));
            }

            var viewModel = new PhotoListViewModel();

            viewModel.ParentName             = person.Fullname;
            viewModel.ParentLinkURL          = this.GetURL <PersonController>(c => c.PersonDetails(personId));
            viewModel.ShowPhotoUploadControl = User.IsInRole(RoleNames.Contributor) || User.IsInRole(RoleNames.Archivist);
            viewModel.PhotoUploadLinkURL     = Url.GetUrl(Upload, personId);
            viewModel.Photos = photos
                               .OrderBy(x => x.Photo.InsertedDateTime).ThenBy(x => x.Photo.PhotoId)
                               .Select(x => new PhotoListViewModel.Photo
            {
                PhotoLinkURL      = this.GetURL(c => c.ListPersonPhotos(personId, x.Photo.PhotoId)),
                PhotoThumbnailURL = x.Photo.GetThumbnailFileURL(),
            }).ToList();

            if (photoId.HasValue)
            {
                var photo = photos.SingleOrDefault(x => x.Photo.PhotoId == photoId.Value);
                if (photo == null)
                {
                    return(Redirect(this.GetURL(c => c.ListPersonPhotos(personId, null))));
                }
                viewModel.CurrentPhotoViewModel = new PhotoViewModel(photo.Photo, this.GetURL(c => c.ListPersonPhotos(personId, photoId.Value)), this);
            }

            return(new ViewModelResult(viewModel));
        }
        public ActionResult ListShowPhotos(int showId, int?photoId = null)
        {
            var show = DatabaseSession.Get <Show>(showId);

            if (photoId == null && show.Photo != null && !show.Photo.IsDefaultNoPic())
            {
                return(Redirect(this.GetURL(c => c.ListShowPhotos(showId, show.Photo.PhotoId))));
            }

            var photos = DatabaseSession.Query <ShowPhoto>()
                         .Where(x => x.Show == show).Fetch(x => x.Photo)
                         .ToList();

            if (photoId == null && photos.Any())
            {
                return(Redirect(this.GetURL(c => c.ListShowPhotos(showId, photos.First().Photo.PhotoId))));
            }

            var viewModel = new PhotoListViewModel();

            viewModel.ParentName             = show.DisplayTitleWithYear;
            viewModel.ParentLinkURL          = this.GetURL <ShowController>(c => c.ShowDetails(showId));
            viewModel.ShowPhotoUploadControl = User.IsInRole(RoleNames.Contributor) || User.IsInRole(RoleNames.Archivist);
            viewModel.PhotoUploadLinkURL     = Url.GetUrl(Upload, showId);
            viewModel.Photos = photos
                               .OrderBy(x => x.Photo.InsertedDateTime).ThenBy(x => x.Photo.PhotoId)
                               .Select(x => new PhotoListViewModel.Photo
            {
                PhotoLinkURL      = this.GetURL(c => c.ListShowPhotos(showId, x.Photo.PhotoId)),
                PhotoThumbnailURL = x.Photo.GetThumbnailFileURL(),
            }).ToList();

            if (photoId.HasValue)
            {
                var photo = photos.SingleOrDefault(x => x.Photo.PhotoId == photoId.Value);
                if (photo == null)
                {
                    return(Redirect(this.GetURL(c => c.ListShowPhotos(showId, null))));
                }
                viewModel.CurrentPhotoViewModel = new PhotoViewModel(photo.Photo, this.GetURL(c => c.ListShowPhotos(showId, photoId.Value)), this);
            }

            return(View(viewModel));
        }
Example #6
0
        public ActionResult PList()
        {
            PhotoListViewModel model   = new PhotoListViewModel();
            string             albumID = Request["albumID"];
            blog_tb_Album      album   = Utility.AlbumBll.GetEntity(albumID);

            if (album == null)
            {
                throw new CustomException("相册不存在");
            }
            if (album.UserID != UserInfo.UserID)
            {
                throw new CustomException("你没有权限管理该相册");
            }
            model.Title           = album.Display + "-查看照片";
            model.PhotoCollection = Utility.PhotoBll.Query(albumID);

            return(View("~/Views/" + Utility.Version + "/Photo/PList.cshtml", model));
        }
 public PhotoListItemAdapter(Activity context, PhotoListViewModel viewModel)
 {
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     if (viewModel == null)
     {
         throw new ArgumentNullException(nameof(viewModel));
     }
     this.context   = context;
     this.viewModel = viewModel;
     this.viewModel.WhenAnyValue(vm => vm.LoadedPhotoData)
     .Where(data => data != null)
     .Select(photos => photos.Select(p => BitmapFactory.DecodeByteArray(p, 0, p.Length)).ToArray())
     .Do(bitmaps => this.bitmaps = bitmaps)
     .Do(b => this.NotifyDataSetChanged())
     .Subscribe();
 }
Example #8
0
 public void Showing_PhotoViewModel_From_ShareViewModel(
     IRouter router,
     PhotoListViewModel photoListViewModel,
     ShareViewModel shareViewModel,
     PhotoViewModel.Params parameters,
     IPagePresenter presenter,
     IRoutedAppHost host)
 {
     "And the PhotoViewModel Parameters"
     .x(() => parameters = new PhotoViewModel.Params()
     {
         Photo = new Photo()
         {
             PhotoUrl = "Url"
         }
     });
     "And a presenter for the view model"
     .x(() => presenter = Substitute.For <IPagePresenter>());
     "That is registered"
     .x(() => Resolver.Register(() => presenter, typeof(IPagePresenter)));
     "And a IRoutedAppHost"
     .x(() => host = new RoutedAppHost(config));
     "That is started"
     .x(async() => await host.StartAsync());
     "And a IRouter"
     .x(() => router = Resolver.GetService <IRouter>());
     "And I'm at ShareViewModel"
     .x(async() => await router.ShowAsync <ShareViewModel>());
     "When I Show the PhotoViewModel"
     .x(async() => await router.ShowAsync <PhotoViewModel, PhotoViewModel.Params>(parameters));
     "Then I Should have navigated to the PhotoViewModel"
     .x(() =>
     {
         Assert.Collection(Resolver.GetService <INavigator>().TransitionStack,
                           t => t.ViewModel.Should().BeOfType <PhotoListViewModel>(),
                           t => t.ViewModel.Should().BeOfType <PhotoViewModel>());
     });
     "And the PhotoViewModel presenter should have recieved a present call"
     .x(() => presenter.Received().PresentAsync(Arg.Any <object>(), Arg.Any <object>()));
 }
Example #9
0
 public ActionResult Photos(string userName, string albumTitle)
 {
     try
     {
         var photoList = new PhotoListViewModel()
         {
             UserName   = userName,
             AlbumTitle = albumTitle,
             Photos     = _mapper.Map <IEnumerable <Photo>, List <PhotoViewModel> >
                              (_photoRepository.AsQueryable()
                              .Where(u => u.Album.AlbumTitle == albumTitle &&
                                     u.Album.User.UserName == userName && u.Album.Public)
                              .OrderBy(p => p.PhotoId).ToList()).ToList()
         };
         return(View(photoList));
     }
     catch (Exception e)
     {
         TempData["result"] = ErrorMsg + e.Message;
         return(RedirectToAction("Index", "Home"));
     }
 }
        public ActionResult Photos()
        {
            PhotoListViewModel      model     = new PhotoListViewModel();
            string                  articleID = Request["articleID"];
            IList <blog_attachment> filelist  = Utility.ArticleBll.GetArticlePhotos(articleID);

            model.PhotoCollection = new List <blog_tb_Photo>();
            foreach (var v in filelist)
            {
                Entity.blog_tb_Photo p = new blog_tb_Photo();
                p.AlbumID  = articleID;
                p.ThumbUrl = v.fileThumbUrl;
                p.Url      = v.fileUrl;
                if (String.IsNullOrEmpty(p.ThumbUrl))
                {
                    p.ThumbUrl = p.Url;
                }
                model.PhotoCollection.Add(p);
            }

            return(View("~/Views/" + Utility.Version + "/Article/Photos.cshtml", model));
        }
Example #11
0
        public IActionResult PhotoList()
        {
            var photos = this.AllPhotos;

            var data = new Dictionary <SchoolYear, Dictionary <Category, Dictionary <PhotoEvent, List <Photo> > > >();

            var schoolYearGroups = photos.GroupBy(x => x.PhotoEvent.SchoolYear).ToDictionary(x => x.Key, x => x.ToList());

            foreach (var schoolYearGroup in schoolYearGroups)
            {
                var schoolYearData = new Dictionary <Category, Dictionary <PhotoEvent, List <Photo> > >();
                var categoryGroups = schoolYearGroup.Value.GroupBy(x => x.PhotoEvent.Category).ToDictionary(x => x.Key, x => x.ToList());

                foreach (var categoryGroup in categoryGroups)
                {
                    var categoryData     = new Dictionary <PhotoEvent, List <Photo> >();
                    var photoEventGroups = categoryGroup.Value.GroupBy(x => x.PhotoEvent).ToDictionary(x => x.Key, x => x.ToList());

                    foreach (var photoEventGroup in photoEventGroups)
                    {
                        categoryData[photoEventGroup.Key] = photoEventGroup.Value;
                    }

                    schoolYearData[categoryGroup.Key] = categoryData;
                }

                data[schoolYearGroup.Key] = schoolYearData;
            }

            var vm = new PhotoListViewModel
            {
                Photos = data
            };

            return(View(vm));
        }
Example #12
0
        public ActionResult Photos(string username)
        {
            UserDto user = readModel.GetUsers().AsParallel().FirstOrDefault(u => u.Username.ToLower() == username.ToLower());

            if (user == null)
                return new HttpNotFoundResult();

            PhotoListViewModel model = new PhotoListViewModel()
            {
                Photos = user.Photos
                    .Where(p => CanSeePhoto(p, (Guid)HttpContext.Items["userid"])).ToList(),
                Username = username
            };

            return View(model);
        }
        public ActionResult ListShowPhotos(int showId, int? photoId = null)
        {
            var show = DatabaseSession.Get<Show>(showId);

            if (photoId == null && show.Photo != null && !show.Photo.IsDefaultNoPic())
            {
                return Redirect(this.GetURL(c => c.ListShowPhotos(showId, show.Photo.PhotoId)));
            }

            var photos = DatabaseSession.Query<ShowPhoto>()
                .Where(x => x.Show == show).Fetch(x => x.Photo)
                .ToList();

            if (photoId == null && photos.Any())
            {
                return Redirect(this.GetURL(c => c.ListShowPhotos(showId, photos.First().Photo.PhotoId)));
            }

            var viewModel = new PhotoListViewModel();
            viewModel.ParentName = show.DisplayTitleWithYear;
            viewModel.ParentLinkURL = this.GetURL<ShowController>(c => c.ShowDetails(showId));
            viewModel.ShowPhotoUploadControl = User.IsInRole(RoleNames.Contributor) || User.IsInRole(RoleNames.Archivist);
            viewModel.PhotoUploadLinkURL = Url.GetUrl(Upload, showId);
            viewModel.Photos = photos
                .OrderBy(x => x.Photo.InsertedDateTime).ThenBy(x => x.Photo.PhotoId)
                .Select(x => new PhotoListViewModel.Photo
                {
                    PhotoLinkURL = this.GetURL(c => c.ListShowPhotos(showId, x.Photo.PhotoId)),
                    PhotoThumbnailURL = x.Photo.GetThumbnailFileURL(),
                }).ToList();

            if (photoId.HasValue)
            {
                var photo = photos.SingleOrDefault(x => x.Photo.PhotoId == photoId.Value);
                if (photo == null)
                {
                    return Redirect(this.GetURL(c => c.ListShowPhotos(showId, null)));
                }
                viewModel.CurrentPhotoViewModel = new PhotoViewModel(photo.Photo, this.GetURL(c => c.ListShowPhotos(showId, photoId.Value)), this);
            }

            return View(viewModel);
        }
 public PhotoListViewModelTests()
 {
     Service   = Substitute.For <IPhotosService>();
     Router    = Substitute.For <IRouter>();
     ViewModel = new PhotoListViewModel(Router, Service);
 }