PAWA.Controllers.EditImage.GetID C# (CSharp) 메소드

GetID() 공개 메소드

public GetID ( string filename ) : int
filename string
리턴 int
        public int GetID(string filename)
        {
            int value = 0;
            PAWAContext dbContext = new PAWAContext();
            var identifier = from f in dbContext.Files
                             where f.Filename == filename
                             select f.FileID;
            value = identifier.SingleOrDefault();
            return value;
        }

Usage Example

예제 #1
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);
            }
        }