Пример #1
0
        void ResetTranslations(ref string[] translations)
        {
            var cookie = new HttpCookie("translations");

            if (translations == null)
            {
                translations = new string[] { }
            }
            ;
            cookie.Value   = string.Join(",", translations);
            cookie.Expires = DateTime.UtcNow.AddYears(10);
            Response.Cookies.Add(cookie);
            SetTranslationsViewBag(translations);
        }

        Quran_Verses CreateVersesModel(
            string[] translations,
            int chapter,
            int verse,
            int lastVerse)
        {
            ViewBag.Chapter           = chapter;
            ViewBag.Verse             = verse;
            ViewBag.CanShowVerseRange = true;
            SetTranslationsViewBag(translations);
            var model = new Quran_Verses(
                chapter: chapter,
                verse: verse,
                lastVerse: lastVerse
                );

            return(model);
        }

        void SetTranslationsViewBag(string[] translations = null)
        {
            if (translations == null)
            {
                if (Request.Cookies.AllKeys.Contains("translations"))
                {
                    translations = Request.Cookies["translations"].Value.Split(',');
                }
                else
                {
                    translations = new string[] { "YusufAli", "Pickthall", "Arabic" }
                };
            }
            ViewBag.Translations = new HashSet <string>(translations, StringComparer.InvariantCultureIgnoreCase);
        }
    }
}
Пример #2
0
        void ResetTranslations(ref string[] translations)
        {
            var cookie = new HttpCookie("translations");

            if (translations == null)
            {
                translations = new string[] { }
            }
            ;
            cookie.Value   = string.Join(",", translations);
            cookie.Expires = DateTime.UtcNow.AddYears(10);
            Response.Cookies.Add(cookie);
            SetTranslationsViewBag(translations);
        }

        Quran_Verses CreateVersesModel(
            string[] translations,
            int chapter,
            int verse,
            int lastVerse,
            int numberOfVersesBeforeAndAfter)
        {
            if (lastVerse == -1)
            {
                lastVerse = verse;
            }

            verse -= numberOfVersesBeforeAndAfter;
            if (verse < 1)
            {
                verse = 1;
            }
            lastVerse += numberOfVersesBeforeAndAfter;

            ViewBag.Chapter           = chapter;
            ViewBag.Verse             = verse;
            ViewBag.CanShowVerseRange = true;
            SetTranslationsViewBag(translations);
            var model = new Quran_Verses(
                chapter: chapter,
                verse: verse,
                lastVerse: lastVerse
                );

            return(model);
        }

        void SetTranslationsViewBag(string[] translations = null)
        {
            if (translations == null)
            {
                if (Request.Cookies.AllKeys.Contains("translations"))
                {
                    translations = Request.Cookies["translations"].Value.Split(',');
                }
                else
                {
                    translations = SharedData.Document.QuranDocument.GetDefaultTranslatorCodes();
                }
            }
            ViewBag.Translations = new HashSet <string>(translations, StringComparer.InvariantCultureIgnoreCase);
        }
    }