public string GetBuildingImage(int buildingId)
        {
            IMAGEBUILDING imageDB          = null;
            string        imageName        = "";
            string        imagePathForHtml = "";
            string        imagePathDB      = "";
            string        folderName       = "";

            var buildingDB = contextDB.BUILDING.Where(b => b.ID == buildingId).FirstOrDefault();

            if (buildingDB != null)
            {
                imageDB = contextDB.IMAGEBUILDING.Where(i => i.ID == buildingDB.IMAGE_ID).FirstOrDefault();
            }

            if (imageDB != null)
            {
                imagePathDB      = imageDB.PATH.ToString();
                folderName       = Path.GetFileName(Path.GetDirectoryName(imagePathDB));
                imageName        = Path.GetFileName(imagePathDB);
                imagePathForHtml = "<img src = '/Images/" + folderName + "/" + imageName + "'" + "id = 'buildingImage'/> <br /> <br /><strong>Building image</strong>";
            }
            else
            {
                imagePathForHtml = "<img src = '/Images/NoImageIcon.jpg' id = 'buildingImage'/>";
            }

            return(imagePathForHtml);
        }
예제 #2
0
        public string GetBuildingImage(int buildingId)
        {
            using (var context = new TownUtilityBillSystemEntities())
            {
                IMAGEBUILDING imageDB          = null;
                string        imageName        = "";
                string        imagePathForHtml = "";
                string        imagePathDB      = "";
                string        folderName       = "";

                var buildingDB = context.BUILDING.Where(b => b.ID == buildingId).FirstOrDefault();

                if (buildingDB != null)
                {
                    imageDB = context.IMAGEBUILDING.Where(i => i.ID == buildingDB.IMAGE_ID).FirstOrDefault();
                }

                if (imageDB != null)
                {
                    imagePathDB      = imageDB.PATH.ToString();
                    folderName       = Path.GetFileName(Path.GetDirectoryName(imagePathDB));
                    imageName        = Path.GetFileName(imagePathDB);
                    imagePathForHtml = "/Images/" + folderName + "/" + imageName;
                }
                return(imagePathForHtml);
            }
        }
예제 #3
0
        public string GetBuildingImage(int buildingId)
        {
            IMAGEBUILDING imageDB     = null;
            string        imageName   = "";
            string        imagePath   = "";
            string        imagePathDB = "";
            string        folderName  = "";

            var buildingDB = contextDB.BUILDING.Where(b => b.ID == buildingId).FirstOrDefault();

            if (buildingDB != null)
            {
                imageDB = contextDB.IMAGEBUILDING.Where(i => i.ID == buildingDB.IMAGE_ID).FirstOrDefault();
            }

            if (imageDB != null)
            {
                imagePathDB = imageDB.PATH.ToString();
                folderName  = Path.GetFileName(Path.GetDirectoryName(imagePathDB));
                imageName   = Path.GetFileName(imagePathDB);
                imagePath   = "/Images/" + folderName + "/" + imageName;
            }
            else
            {
                imagePath = "/Images/NoImageIcon.jpg";
            }

            return(imagePath);
        }