Beispiel #1
0
        public void GetSingleNews(int newsId)
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                var    singleNewsDB    = context.NEWS.Find(newsId);
                string currentLanguage = HelperMethod.GetCurrentLanguage();

                var newsTitle = context.NEWS_TITLEs.
                                Where(t => t.NEWS_ID == singleNewsDB.ID).
                                Where(t => t.LANGUAGE == currentLanguage).
                                FirstOrDefault().TITLE;

                var chaptersDB = context.NEWS_CHAPTERs.
                                 Where(c => c.NEWS_ID == newsId).
                                 Where(c => c.LANGUAGE == currentLanguage).
                                 ToList();

                SingleNews.Title = newsTitle;
                SingleNews.Date  = singleNewsDB.DATE;

                foreach (var ch in chaptersDB)
                {
                    SingleNews.NewsChapters.Add(new NewsChapter()
                    {
                        Id = ch.ID, Text = ch.TEXT
                    });
                }
            }
        }
        public ActionResult EditMeterData(int meterItemId)
        {
            var model = new MeterItemModel();

            model.GetMeterAndDataToEdit(meterItemId);

            ViewBag.CurrentCulture = HelperMethod.GetCurrentLanguage();

            return(View(model));
        }
Beispiel #3
0
        /// <summary>
        /// Rerurns news titles list for a slide-show
        /// </summary>
        public void GetNewsTitlesForSlideShow()
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                var    newsDB          = context.NEWS.ToList();
                var    newsTitlesDB    = context.NEWS_TITLEs.ToList();
                string currentLanguage = HelperMethod.GetCurrentLanguage();

                foreach (var n in newsDB)
                {
                    string newsTitle = newsTitlesDB.
                                       Where(t => t.NEWS_ID == n.ID).
                                       Where(t => t.LANGUAGE == currentLanguage).
                                       FirstOrDefault().TITLE;

                    NewsList.Add(new News()
                    {
                        Id = n.ID, Date = n.DATE, Title = newsTitle, ImagePath = GetNewsImage(n.IMAGE_ID)
                    });
                }
            }
        }
Beispiel #4
0
        public string GetBuildingImage(int buildingId)
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                IMAGE_BUILDING imageDB          = null;
                string         imageName        = "";
                string         imagePathForHtml = "";
                string         imagePathDB      = "";
                string         folderName       = "";

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

                imageDB = (buildingDB != null) ? context.IMAGE_BUILDINGs.Where(i => i.ID == buildingDB.IMAGE_ID).FirstOrDefault() : null;

                if (imageDB != null)
                {
                    imagePathDB      = imageDB.PATH.ToString();
                    folderName       = Path.GetFileName(Path.GetDirectoryName(imagePathDB));
                    imageName        = Path.GetFileName(imagePathDB);
                    imagePathForHtml = "<img src = '/Content/Images/TownBuildings/" + folderName + "/" + imageName + "'" + "id = 'buildingImage'/> <br /> <br /><strong>" + Localization.BuildingImage + "</strong>";
                }
                else
                {
                    switch (HelperMethod.GetCurrentLanguage())
                    {
                    case "da":
                        imagePathForHtml = "<img src = '/Content/Images/EmptyImages/NoImageBuildingDa.jpg' id = 'buildingImage'/>";
                        break;

                    default:
                        imagePathForHtml = "<img src = '/Content/Images/EmptyImages/NoImageBuildingEn.jpg' id = 'buildingImage'/>";
                        break;
                    }
                }

                return(imagePathForHtml);
            }
        }
Beispiel #5
0
        public static string GetBuildingImageForCustomerDetailsView(int buildingId)
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                IMAGE_BUILDING imageDB     = null;
                string         imageName   = "";
                string         imagePath   = "";
                string         imagePathDB = "";
                string         folderName  = "";

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

                if (buildingDB != null)
                {
                    imageDB = context.IMAGE_BUILDINGs.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   = "/Content/Images/TownBuildings/" + folderName + "/" + imageName;
                }
                else
                {
                    imagePath = "/Content/Images/EmptyImages/NoImageBuilding" + HelperMethod.UppercaseFirstLetter(HelperMethod.GetCurrentLanguage()) + ".jpg";
                }

                return(imagePath);
            }
        }
        public void CheckGetCurrentLanguage()
        {
            string currentCulture = HelperMethod.GetCurrentLanguage();

            Assert.IsFalse(String.IsNullOrEmpty(currentCulture));
        }