예제 #1
0
        public ViewResult Index(string query, string category, int?page, string language, int?period)
        {
            var categories        = _categoryProvider.Get();
            var videoNewsProvider = _videoNewsProvider.Get();
            var languages         = _languageProvider.Get();

            return
                (View(new NewsViewModel(videoNewsProvider, categories, languages, query, category, page, language, period)));
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Gets this instance.
        /// </summary>
        ///
        /// <param name="code">
        ///     the code.
        /// </param>
        /// <param name="page">
        ///     (Optional) the page.
        /// </param>
        /// <param name="size">
        ///     (Optional) the size.
        /// </param>
        ///
        /// <returns>
        ///     IReadOnlyList{ILanguageResource}.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public static IPagedList <ILanguageResource> Get(LanguageCode code, int page = 0, int size = 10)
        {
            ILanguageProvider provider = Container.TryGet <ILanguageProvider>();

            if (provider != null)
            {
                return(provider.Get(code, page, size));
            }

            return(PagedList <ILanguageResource> .Empty);
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Gets a resource.
        /// </summary>
        ///
        /// <remarks>
        ///     Anwar Javed, 03/05/2014 5:08 PM.
        /// </remarks>
        ///
        /// <param name="key">
        ///     The key.
        /// </param>
        /// <param name="code">
        ///     (Optional) the code.
        /// </param>
        ///
        /// <returns>
        ///     The resource.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public static ILanguageResource GetResource(string key, LanguageCode code = LanguageCode.English)
        {
            ILanguageProvider provider = Container.TryGet <ILanguageProvider>();

            if (provider != null)
            {
                return(provider.Get(key, code));
            }

            return(null);
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Gets the resources.
        /// </summary>
        ///
        /// <remarks>
        ///     Anwar Javed, 03/05/2014 5:08 PM.
        /// </remarks>
        ///
        /// <param name="key">
        ///     The key.
        /// </param>
        ///
        /// <returns>
        ///     The resources.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public static IReadOnlyList <ILanguageResource> GetResources(string key)
        {
            ILanguageProvider provider = Container.TryGet <ILanguageProvider>();

            if (provider != null)
            {
                return(provider.Get(key));
            }

            return(PagedList <ILanguageResource> .Empty);
        }
        public static IPagedList <ILanguageResource> Get(
            string sortBy,
            string sortDirection,
            int page = 0,
            int size = 10)
        {
            ILanguageProvider provider = Container.TryGet <ILanguageProvider>();

            if (provider != null)
            {
                return(provider.Get(sortBy, sortDirection, page, size));
            }

            return(PagedList <ILanguageResource> .Empty);
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Gets language dictionary.
        /// </summary>
        ///
        /// <returns>
        ///     The language dictionary.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        private static Dictionary <string, LanguageResource> GetLanguageDictionary()
        {
            Dictionary <string, LanguageResource> dictionary = new Dictionary <string, LanguageResource>(StringComparer.OrdinalIgnoreCase);
            ILanguageProvider provider = Container.TryGet <ILanguageProvider>();
            IEnumerable <IGrouping <LanguageCode, ILanguageResource> > list = provider.Get(0, int.MaxValue).Distinct().GroupBy(x => x.Code);

            foreach (var langResources in list)
            {
                foreach (var languageResource in langResources)
                {
                    LanguageResource resource = new LanguageResource(languageResource);
                    string           key      = langResources.Key.ToString("G").ToLowerInvariant() + "[" + resource.Key + "]";
                    if (!dictionary.ContainsKey(key))
                    {
                        dictionary.Add(key, resource);
                    }
                }
            }

            return(dictionary);
        }