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")); }
public IActionResult Update() { string id = _http.HttpContext.Request.Query["q"]; string title = _http.HttpContext.Request.Query["title"]; var query = _db.Gallery.Where(g => g.GalleryName == title && g.GalleryRemoteID == id).FirstOrDefault(); var model = new PersonalWebsiteMVC.Models.Gallery(); model.GalleryName = query.GalleryName; model.GalleryLocation = query.GalleryLocation; model.GalleryDescription = query.GalleryDescription; model.GalleryRemoteID = query.GalleryRemoteID; return(View(model)); }
public IActionResult Update(PersonalWebsiteMVC.Models.Gallery model) { if (ModelState.IsValid) { var query = _db.Gallery.Where(u => u.GalleryRemoteID.Equals(model.GalleryRemoteID)).FirstOrDefault(); query.GalleryName = model.GalleryName; query.GalleryLocation = model.GalleryLocation; query.GalleryDescription = model.GalleryDescription; _db.Gallery.Update(query); _db.SaveChanges(); return(RedirectToAction("Index", "Gallery")); } return(View()); }
public IViewComponentResult Invoke(string galleryId, string galleryName) { var query = _db.Gallery.Where(g => g.GalleryRemoteID.Equals(galleryId) && g.GalleryName.Equals(galleryName)).FirstOrDefault(); if (query == null) { var model = new PersonalWebsiteMVC.Models.Gallery(); model.GalleryName = galleryName; model.GalleryRemoteID = galleryId; return(View("FormView1", model)); } else { var model = new PersonalWebsiteMVC.Models.Gallery(); model.GalleryName = query.GalleryName; model.GalleryLocation = query.GalleryLocation; model.GalleryDescription = query.GalleryDescription; model.GalleryRemoteID = query.GalleryRemoteID; return(View("FormView2", model)); } }