Exemple #1
0
        // ************************************************************************

        public ActionResult ViewPhotos(int id)
        {
            var vm = new PhotosVM()
            {
                AlbumId = id,
                Photo   = new Photo(),
                Photos  = _photoService.ListPhotos(id)
            };

            return(View(vm));
        }
Exemple #2
0
        public ActionResult Photos()
        {
            PhotosBL photosBL = new PhotosBL();
            PhotosVM photosVM = new PhotosVM();

            List <Photo> list = photosBL.GetPhotos();
            int          i, n, j;

            photosVM.albums = new List <List <Photo> >();

            List <string> names = new List <string>();

            if (list != null)
            {
                n = 1;
                names.Add(list[0].photoalbum);
                for (i = 1; i < list.Count; i++)
                {
                    if (list[i].photoalbum != list[i - 1].photoalbum)
                    {
                        if (!names.Contains(list[i].photoalbum))
                        {
                            n += 1;
                            names.Add(list[i].photoalbum);
                        }
                    }
                }

                for (i = 0; i < n; i++)
                {
                    List <Photo> tmp = new List <Photo>();
                    foreach (Photo p in list)
                    {
                        if (p.photoalbum == names[i])
                        {
                            tmp.Add(p);
                        }
                    }

                    photosVM.albums.Add(tmp);
                }
            }
            photosVM.albums.Reverse();
            return(View(photosVM));
        }