Ejemplo n.º 1
0
        public ActionResult UpdateImage(FormCollection form, string saveImage, string cancelImage)
        {
            EditImage ei = new EditImage();
            Tools tool = new Tools();

            int index = Convert.ToInt32(form["FileID"]);
            var files = from f in dbContext.Files where f.FileID == index select f;
            var file = files.First();

            file.Description = form["Description"];
            if (form["FolderID"] == "")
            ViewBag.FolderID = new SelectList(dbContext.Folders, "FolderID", "FolderName", file.FolderID);

            if (saveImage != null)
            {
                file.Tags = ei.stringOfTags(form);
                file.FolderID = ei.InFolderSetting(form["FolderID"]);

                if (ModelState.IsValid)
                {
                    dbContext.Entry(file).State = EntityState.Modified;
                    dbContext.SaveChanges();
                    return RedirectToAction("./../Image/DisplayImage", new { filename = form["Filename"] });
                }
                return View(file);
            }
            else
            {
                return RedirectToAction("./../Image/DisplayImage", new { filename = form["Filename"] });
            }
        }
Ejemplo n.º 2
0
        public ActionResult DisplayImage(string fileName, string editImage, string deleteImage, string ShareToFacebook)
        {
            //If they want to delete
            if (deleteImage != null)
            {

                //Call Delete Method
                DeleteImage delImage = new DeleteImage();
                delImage.deleteSingleImage(Request, Server, fileName);

                //Navigate to album
                return RedirectToAction("./../Home/Album");
            }
            else if (editImage != null)
            {
                EditImage ei = new EditImage();
                int index = ei.GetID(fileName);
                return RedirectToAction("./../Image/UpdateImage", new{fileID = index}); ;
            }
                 //If they want to share to Facebook
            else if (ShareToFacebook != null)
            {
                SocialMediaTools SocTools = new SocialMediaTools();
                FacebookClient FBClient = new FacebookClient();

                //Create a custom query for facebook, they then return a in-url code which we exchange for a user token
                var loginUrl = FBClient.GetLoginUrl(new
                {
                    client_id = "333143620161224",
                    redirect_uri = (Request.Url.AbsoluteUri.ToString() + "?filename=" + fileName),
                    response_type = "code",
                    scope = "publish_actions,publish_stream"
                });
                //Reload the page and get a new Acess Token for this user --> Go to HTTPPOST
                Response.Redirect(loginUrl.AbsoluteUri);
                return View(fileName);
            }
            else

            {
                //Not deleting, do nothing
                return DisplayImage(fileName);
            }
        }
Ejemplo n.º 3
0
        public ActionResult UpdateImage(int fileID)
        {
            EditImage ei = new EditImage();
            PAWA.Models.File file = dbContext.Files.Find(fileID);
            if (file == null)
            {
                return HttpNotFound(fileID.ToString());
            }

            string tags = file.Tags.ToString();
            ViewBag.Tags = PAWA.Classes.DisplayImage.GetTags(dbContext, tags);
            ViewBag.FolderID = new SelectList(dbContext.Folders, "FolderID", "FolderName", file.FolderID);
            return View(file);
        }