public IActionResult AddGalleryToDb(PersonalWebsiteMVC.Models.Gallery model)
        {
            var g = new PersonalWebsiteMVC.Models.Gallery();

            g.GalleryName     = model.GalleryName;
            g.GalleryLocation = model.GalleryLocation;
            g.GalleryRemoteID = model.GalleryRemoteID;
            _db.Gallery.Add(g);

            var album = _Graph.GraphClient().Result.Drives["*****@*****.**"].Items[model.GalleryRemoteID].Children.Request().Expand("thumbnails").GetAsync().Result;

            for (int i = 0; i < album.Count(); i++)
            {
                for (int p = 0; p < album[i].Thumbnails.Count(); p++)
                {
                    var pic = new PersonalWebsiteMVC.Models.Photos();
                    pic.GalleryRemoteID = model.GalleryRemoteID;
                    pic.PhotoRemoteID   = album[i].Id;
                    pic.PhotoName       = album[i].Name;
                    pic.PhotoLocation   = model.GalleryLocation;
                    _db.Photos.Add(pic);
                    _db.SaveChanges();
                }
            }
            return(RedirectToAction("Index", "Gallery"));
        }
Esempio n. 2
0
        public IActionResult RemovePicsFromDb(PersonalWebsiteMVC.Models.Photos model)
        {
            var query = from c in _db.Photos where c.GalleryRemoteID.Equals(HttpContext.Request.Query["q"]) select c;

            _db.RemoveRange(query);
            _db.SaveChanges();
            //return View("/Areas/Admin/Views/Gallery/Album.cshtml");
            return(RedirectToAction("Album", "Gallery", new { q = HttpContext.Request.Query["q"], Area = "Admin" }));
        }
Esempio n. 3
0
        public IActionResult AddPicToDb(PersonalWebsiteMVC.Models.Photos model, IFormCollection form)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < form["PicName"].Count(); i++)
            {
                var p = new PersonalWebsiteMVC.Models.Photos();
                p.PhotoName       = model.PhotoName;
                p.PhotoRemoteID   = model.PhotoRemoteID;
                p.PhotoMediumUrl  = model.PhotoMediumUrl;
                p.PhotoLargeUrl   = model.PhotoLargeUrl;
                p.GalleryRemoteID = HttpContext.Request.Query["q"];
                _db.Photos.Add(p);
                _db.SaveChanges();
            }
            return(RedirectToAction("Album", new { q = HttpContext.Request.Query["q"], Area = "Admin" }));
        }
        public IViewComponentResult Invoke(string picName, string albumId)
        {
            var query = _db.Photos.Where(p => p.PhotoName == picName && p.GalleryRemoteID == albumId).FirstOrDefault();

            if (query == null)
            {
                var model = new PersonalWebsiteMVC.Models.Photos();
                model.GalleryRemoteID = albumId;
                model.PhotoName       = picName;
                return(View("FormView1", model));
            }
            else
            {
                var model = new PersonalWebsiteMVC.Models.Photos();
                model.PhotoName        = query.PhotoName;
                model.PhotoLocation    = query.PhotoLocation;
                model.PhotoDescription = query.PhotoDescription;
                return(View("FormView2", model));
            }
        }