public IActionResult ShowAlbumWithCircle(ShowAlbumModel model, int page) { var pictureList = new List <string>(); var albumPath = $"{_hostingEnvironment.WebRootPath}/{model.Path}"; //先得到albumPath下的所有图片 var allPicturesUnordered = Directory.GetFiles(albumPath); //按照上传时间排序 var allPictures = allPicturesUnordered.OrderBy(q => new FileInfo(q).CreationTime).ToList(); int countOfPhotos = GetCountOfPhotos(); ViewData["countOfPhotos"] = countOfPhotos; //取第page*30+30张图片 for (int i = (page - 1) * countOfPhotos; i < page * countOfPhotos && i < allPictures.Count(); i++) { allPictures[i] = allPictures[i].Replace('\\', '/'); // D:/asdasdad/asdsad/asdasd/images/46f060ffffffss/1.jpg var _index = allPictures[i].LastIndexOf('/'); var pictureName = allPictures[i].Substring(_index); var picturePath = model.Path + pictureName; pictureList.Add(picturePath); } return(View(pictureList)); }
public IActionResult ShowAlbum(ShowAlbumModel model, int Page) { if (string.IsNullOrEmpty(model.Path)) { return(Json(new { })); } var pictureList = new List <string> (); var albumPathTemp = model.Path; var rootPath = _hostingEnvironment.WebRootPath; var albumPath = $"{rootPath}/{albumPathTemp}"; //先得到albumPath下的所有图片 var allPicturesUnordered = Directory.GetFiles(albumPath); //按照上传时间排序 var allPictures = allPicturesUnordered.OrderBy(q => new FileInfo(q).CreationTime).ToList(); int countOfPhotos = GetCountOfPhotos(); ViewData["CountOfPhotos"] = countOfPhotos.ToString(); //取第page*30+30张图片 for (int i = (Page - 1) * countOfPhotos; i < Page * countOfPhotos && i < allPictures.Count(); i++) { allPictures[i] = allPictures[i].Replace('\\', '/'); var index = allPictures[i].LastIndexOf('/') + 1; var pictureName = allPictures[i].Substring(index); pictureList.Add(pictureName); } return(Json(new { pictures = pictureList, count = allPictures.Count() })); }
public IActionResult ShowAlbum(string albumId, string returnUrl = null) { ViewData["AlbumId"] = albumId; ViewData["returnUrl"] = returnUrl; var model = new ShowAlbumModel(); var query = _context.Albums.Where(q => q.Id == albumId); if (query.Any()) { var album = query.First(); model.Path = album.AlbumPath; } return(View(model)); }
public IActionResult ShowAlbumWithCarousel(ShowAlbumModel model, int page, int index) { //return Json (new { pictures = pictureList, count = allPictures.Count () }); if (string.IsNullOrEmpty(model.Path)) { return(Json(new { })); } var pictureList = new List <string>(); var albumPathTemp = model.Path; var rootPath = _hostingEnvironment.WebRootPath; var albumPath = $"{rootPath}/{albumPathTemp}"; //先得到albumPath下的所有图片 var allPicturesUnordered = Directory.GetFiles(albumPath); //按照上传时间排序 var allPictures = allPicturesUnordered.OrderBy(q => new FileInfo(q).CreationTime).ToList(); int countOfPhotos = GetCountOfPhotos(); ViewData["CountOfPhotos"] = countOfPhotos; //取第page*30+30张图片 for (int i = (page - 1) * countOfPhotos; i < page * countOfPhotos && i < allPictures.Count(); i++) { allPictures[i] = allPictures[i].Replace('\\', '/'); // D:/asdasdad/asdsad/asdasd/images/46f060ffffffss/1.jpg var _index = allPictures[i].LastIndexOf('/'); var pictureName = allPictures[i].Substring(_index); var picturePath = model.Path + pictureName; pictureList.Add(picturePath); } return(View(new ShowAlbumWithCarouselModel { Pictures = pictureList, Index = index })); }