public ActionResult Index() { if (CurrentUser.IsAdministrator) { var galleryModel = new GalleryModel(); IList <Photo> photos = new List <Photo>(_photoManager.Get(1, _config.PhotosPerPage, NotApproved)); foreach (var photo in photos) { galleryModel.PhotoModels.Add(new PhotoModel { PhotoId = photo.PhotoId, UserId = photo.UserId, Description = photo.Description, Title = photo.Title, FileName = photo.FileName, Approved = photo.Approved, SubmittedBy = photo.SubmittedBy, SubmittedOn = photo.CreatedOnDateUtc }); } return(View(galleryModel)); } return(RedirectToAction("Index", "Home")); }
public ActionResult Index(int?page) { int pageing = 1; if (page.HasValue) { pageing = page.Value; } var from = (pageing - 1) * _config.PhotosPerPage + 1; var to = pageing * _config.PhotosPerPage; IList <Photo> photos = _photoManager.Get(from, to); ViewBag.Page = pageing; return(View(PhotoListToGalleryModel(photos))); }
// GET: api/Photo public async Task <IHttpActionResult> Get() { var results = await photoManager.Get(); return(Ok(new { photos = results })); }