public ActionResult Delete(string Id) { try { Photo model = photoRepository.GetPhotoFromDbById(new Guid(Id)); if (model.UserID == userID) { photoRepository.DeletePhotoFromDB(model); string fullPath = Request.MapPath(model.Path); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } } catch { } List <Photo> photosFromDB = photoRepository.GetPhotoFromDbByUserId(userID); ICollection <IndexPhotoViewModels> models = new List <IndexPhotoViewModels>(); photosFromDB.ForEach(x => models.Add(PhotoMapper.MapIndexPhotoViewModel(x))); return(PartialView("_Images", models)); }
public ActionResult AlbumPhotoes(string id) { List <Photo> photosFromDB = photoRepository.GetAllPhotoesInAlbumByID(id); List <IndexPhotoViewModel> photos = new List <IndexPhotoViewModel>(); photosFromDB.ForEach(x => photos.Add(PhotoMapper.MapIndexPhotoViewModel(x))); return(PartialView("_thumbnails", photos)); }
// GET: User/Edit public ActionResult Index() { List <Photo> photosFromDB = photoRepository.GetPhotoFromDbByUserId(userID); ICollection <IndexPhotoViewModels> model = new List <IndexPhotoViewModels>(); photosFromDB.ForEach(x => model.Add(PhotoMapper.MapIndexPhotoViewModel(x))); return(View(model)); }
public ActionResult Index() { List <Photo> photosFromDB = photoRepository.GetAllPhotosFromDb(); List <IndexPhotoViewModel> photos = new List <IndexPhotoViewModel>(); photosFromDB.ForEach(x => photos.Add(PhotoMapper.MapIndexPhotoViewModel(x))); return(View(photos)); }
public ActionResult Data() { var model = new DataViewModel() { users = userRepository.GetAllUsers().Count().ToString(), albums = albumRepository.GettAllAlbums().Count().ToString(), comments = commentRepository.GetAllComments().Count().ToString(), photos = photoRepository.GetAllPhotosFromDb().Count().ToString(), latest = PhotoMapper.MapIndexPhotoViewModel(photoRepository.GetLastAddedPhoto()).Path }; return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult Media(string Search, string Filter) { if (Filter == "photo") { List <Photo> photosFromDB = photoRepository.GetSearchPhotosFromDb(Search); List <IndexPhotoViewModel> photos = new List <IndexPhotoViewModel>(); photosFromDB.ForEach(x => photos.Add(PhotoMapper.MapIndexPhotoViewModel(x))); return(PartialView("_thumbnails", photos)); } else { List <Album> albumsFromDB = albumRepository.GetSearchAlbumsFromDB(Search).Where(x => x.Photos.Count() > 0).ToList(); List <AlbumViewModel> albums = new List <AlbumViewModel>(); albumsFromDB.ForEach(x => albums.Add(AlbumMapper.MapAlbumViewModel(x, photoRepository))); return(PartialView("_thumbnailsAlbum", albums)); } }