예제 #1
0
        public static string GetTextView(string valNameView, string valKey, string valLang)
        {
            string            vResult   = string.Empty;
            ViewTextViewModel vTextView = Startup._vViewInfo.ViewText.FirstOrDefault(x => x.NameView == valNameView);

            if (vTextView != null)
            {
                KeyValuePair <string, List <Dictionary <string, string> > > vElement = new KeyValuePair <string, List <Dictionary <string, string> > >();
                foreach (Dictionary <string, List <Dictionary <string, string> > > vItem in vTextView.Elements)
                {
                    if (vItem.Select(i => i.Key == valKey).FirstOrDefault())
                    {
                        vElement = vItem.FirstOrDefault(i => i.Key == valKey);
                        break;
                    }
                }
                List <Dictionary <string, string> > vItemElement     = vElement.Value;
                KeyValuePair <string, string>       vElementLanguage = new KeyValuePair <string, string>();
                foreach (Dictionary <string, string> vItem in vItemElement)
                {
                    if (vItem.Select(i => i.Key.ToUpper() == valLang).FirstOrDefault())
                    {
                        vElementLanguage = vItem.FirstOrDefault(i => i.Key.ToUpper() == valLang);
                        break;
                    }
                }

                vResult = vElementLanguage.Value;
            }
            return(vResult);
        }
예제 #2
0
        // GET: Home
        public ActionResult ViewText(int blocksPerPage = 6, int stringsPerBlock = 3)
        {
            if (blocksPerPage <= 0 || stringsPerBlock <= 0)
            {
                ViewBag.ErrorMessage = "Parameters can not be negative!";
                return(View("_Error",
                            new ViewTextLayoutParameters
                {
                    BlockPerPage = blocksPerPage,
                    StringsPerBlock = stringsPerBlock
                }
                            ));
            }

            var path    = HostingEnvironment.MapPath("~/Content/data.txt");
            var strings = FileStringsGetter.GetStrings(path);

            //last parameter is zero to return first page.
            var page       = PageBuilder.GetPage(strings, blocksPerPage, stringsPerBlock, 0);
            var pagesCount = PagesCounter.GetPagesCount(strings, blocksPerPage, stringsPerBlock);

            var viewModel = new ViewTextViewModel()
            {
                Page       = page,
                PagesCount = pagesCount,
                ViewTextLayoutParameters = new ViewTextLayoutParameters
                {
                    BlockPerPage    = blocksPerPage,
                    StringsPerBlock = stringsPerBlock
                }
            };

            return(View(viewModel));
        }