Exemple #1
0
        public ActionResult Photos(string key)
        {
            int total;
            int pageNo;

            if (!int.TryParse(key, out pageNo))
            {
                pageNo = 1;
            }
            var list       = _photosService.AllPhotos(out total, "0-", pageNo, DependencyConfig.GlobalPageSize);
            var pagedList  = new StaticPagedList <Guid>(list, pageNo, DependencyConfig.GlobalPageSize, total);
            var photoGuids = new PagedListModel <Guid> {
                List = pagedList, Total = total
            };
            var dictionaryPhotos   = new Dictionary <Guid, PhotoModel>();
            var dictionaryProfiles = new Dictionary <Guid, ProfileModel>();

            foreach (var guid in list)
            {
                var photo = _photosService.GetByGuid(guid);
                if (photo != null)
                {
                    dictionaryPhotos.Add(guid, Mapper.Map <PhotoModel>(photo));
                    dictionaryProfiles.Add(guid, Mapper.Map <ProfileModel>(ProfileService.GetProfile(photo.ProfileId)));
                }
            }
            var model = new UtilitiesPhotosModel {
                PhotoGuids = photoGuids, Photos = dictionaryPhotos, Profiles = dictionaryProfiles
            };

            return(View(model));
        }