public ActionResult DeletePhoto(int id) { PhotosBL photoBL = new PhotosBL(); List <Photo> itemList = photoBL.GetPhotos(); Photo photo = itemList.Where(u => u.PhotoId == id).Single(); photoBL.DeletePhoto(photo); itemList = photoBL.GetPhotos(); bool albumExist = false; foreach (Photo p in itemList) { if (p.photoalbum == photo.photoalbum) { albumExist = true; } } if (albumExist) { return(RedirectToAction("Album", "Home", new { name = photo.photoalbum })); } else { return(RedirectToAction("Photos", "Home")); } }
public void GetById() { //Arrange PhotosBL target = DI.Resolve <PhotosBL>(); //Act Photo photo = target.GetById(1); //Asserts Assert.That(photo.WaterMarked, !Is.Null); }
public void ApplyWaterMark() { //Arrange ResetDataBase(); PhotosBL target = DI.Resolve <PhotosBL>(); //Act Photo photo = target.ApplyWaterMark(18, "test"); //Asserts Assert.That(photo.WaterMarked.Data.Length > 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)); }
public ActionResult AddPhotos(string albumname, IEnumerable <HttpPostedFileBase> uploads) { PhotosBL photoBL = new PhotosBL(); foreach (var file in uploads) { if (file != null) { string filename = System.IO.Path.GetFileName(file.FileName); file.SaveAs(Server.MapPath("~/Assets/img/photoalbums/" + filename)); Photo p = new Photo(); p.photoalbum = albumname; p.path = "/Assets/img/photoalbums/" + filename; photoBL.AddPhoto(p); } } return(RedirectToAction("Photos", "Home")); }
public ActionResult Album(string name) { AlbumVM albumVM = new AlbumVM(); PhotosBL photosBL = new PhotosBL(); List <Photo> list = photosBL.GetPhotos(); albumVM.album = new List <Photo>(); foreach (Photo p in list) { if (p.photoalbum == name) { albumVM.album.Add(p); } } if (albumVM.album == null) { return(RedirectToAction("Photos", "Home")); } return(View(albumVM)); }
public ProductCategoriesController(ProductCategoriesBL productCategoriesBL, PhotosBL photosBL) { _productCategoriesBL = productCategoriesBL; _photosBL = photosBL; }
public PhotosController(PhotosBL photosBL) { _photosBL = photosBL; }