Beispiel #1
0
        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"));
            }
        }
Beispiel #2
0
        public void GetById()
        {
            //Arrange
            PhotosBL target = DI.Resolve <PhotosBL>();

            //Act
            Photo photo = target.GetById(1);

            //Asserts
            Assert.That(photo.WaterMarked, !Is.Null);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
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));
        }
Beispiel #5
0
        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"));
        }
Beispiel #6
0
        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));
        }
Beispiel #7
0
 public ProductCategoriesController(ProductCategoriesBL productCategoriesBL, PhotosBL photosBL)
 {
     _productCategoriesBL = productCategoriesBL;
     _photosBL            = photosBL;
 }
Beispiel #8
0
 public PhotosController(PhotosBL photosBL)
 {
     _photosBL = photosBL;
 }