Ejemplo n.º 1
0
        public ActionResult Get(string owner, string album)
        {
            if (string.IsNullOrEmpty(album))
            {
                return RedirectToAction("MyAlbums", new { owner = owner });
            }

            AlbumViewModel albumViewModel = new AlbumViewModel();
            PhotoViewModel photoViewModel = new PhotoViewModel();

            albumViewModel.Album = album;
            photoViewModel.Album = album;
            albumViewModel.Owner = owner.ToLowerInvariant();
            photoViewModel.Owner = owner.ToLowerInvariant();

            var albums = this.repository.GetAlbumsByOwner(owner.ToLowerInvariant());
            var foundAlbum = albums.SingleOrDefault(a => a.AlbumId == album || a.Title == album);

            if (foundAlbum != null)
            {
                photoViewModel.Photos = this.repository.GetPhotosByAlbum(owner, foundAlbum.AlbumId);
                return View(photoViewModel);
            }

            // no album found
            return View(new PhotoViewModel());
        }
Ejemplo n.º 2
0
        public ActionResult MyAlbums(string owner)
        {
            AlbumViewModel albumViewModel = new AlbumViewModel();
            PhotoViewModel photoViewModel = new PhotoViewModel();

            albumViewModel.Owner = owner.ToLowerInvariant();
            photoViewModel.Owner = owner.ToLowerInvariant();

            var albums = this.repository.GetAlbumsByOwner(owner.ToLowerInvariant());

            // if there are more than 1 album with photos for this user
            // then return a view of the albums for them
            if (albums.Where(a => a.HasPhotos).Count() > 1)
            {
                albumViewModel.Albums = albums;
                return View("Index", albumViewModel);
            }

            // if there is only 1 album, just return photos for it
            if (albums.Where(a => a.HasPhotos).Count() == 1)
            {
                photoViewModel.Photos = this.repository.GetPhotosByAlbum(owner, albums.First().AlbumId);
                return View("Get", photoViewModel);
            }

            // there are no albums for this user
            return View("Get", new PhotoViewModel());
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            AlbumViewModel albumViewModel = new AlbumViewModel();

            albumViewModel.Albums = this.repository.GetAlbums();

            return View(albumViewModel);
        }