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);
}
}