Exemplo n.º 1
0
        public static Page <T> GetPage <T>(this Microsoft.EntityFrameworkCore.DbSet <T> list, int page_index, int page_size, Func <T, object> order_by_selector)
            where T : class
        {
            var res = list.OrderBy(order_by_selector)
                      .Skip(page_index * page_size)
                      .Take(page_size)
                      .ToArray();

            if (res == null || res.Length == 0)
            {
                return(null);
            }

            var tot_items = list.Count();
            var tot_pages = tot_items / page_size;

            if (tot_items < page_size)
            {
                tot_pages = 1;
            }

            return(new Page <T>()
            {
                Index = page_index, Items = res, TotalPages = tot_pages
            });
        }
Exemplo n.º 2
0
 public override void InitDb(WebCoreDbContext context)
 {
     Microsoft.EntityFrameworkCore.DbSet <MasterList> masterList = context.MasterLists;
     if (masterList.Count() == 0)
     {
         masterList.Add(new MasterList()
         {
             Group        = ConstantConfig.MasterListMasterGroup,
             Value        = ConstantConfig.MasterListMasterGroup,
             RecordStatus = ConstantConfig.RecordStatusConfig.Active,
             OrderNo      = 0
         });
         context.SaveChanges();
     }
 }
Exemplo n.º 3
0
        public override void InitDb(WebCoreDbContext context)
        {
            Microsoft.EntityFrameworkCore.DbSet <Language> languages = context.Languages;
            if (languages.Count() == 0)
            {
                languages.Add(new Language()
                {
                    LangCode = "ar-AE", LangName = "Arabic (U.A.E.)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-BH", LangName = "Arabic (Bahrain)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-DZ", LangName = "Arabic (Algeria)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-EG", LangName = "Arabic (Egypt)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-IQ", LangName = "Arabic (Iraq)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-JO", LangName = "Arabic (Jordan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-KW", LangName = "Arabic (Kuwait)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-LB", LangName = "Arabic (Lebanon)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-LY", LangName = "Arabic (Libya)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-MA", LangName = "Arabic (Morocco)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-OM", LangName = "Arabic (Oman)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-QA", LangName = "Arabic (Qatar)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-SA", LangName = "Arabic (Saudi Arabia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-SY", LangName = "Arabic (Syria)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-TN", LangName = "Arabic (Tunisia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ar-YE", LangName = "Arabic (Yemen)"
                });
                languages.Add(new Language()
                {
                    LangCode = "az-AZ", LangName = "Azeri (Latin) (Azerbaijan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "az-AZ", LangName = "Azeri (Cyrillic) (Azerbaijan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "be-BY", LangName = "Belarusian (Belarus)"
                });
                languages.Add(new Language()
                {
                    LangCode = "bg-BG", LangName = "Bulgarian (Bulgaria)"
                });
                languages.Add(new Language()
                {
                    LangCode = "bs-BA", LangName = "Bosnian (Bosnia and Herzegovina)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ca-ES", LangName = "Catalan (Spain)"
                });
                languages.Add(new Language()
                {
                    LangCode = "cs-CZ", LangName = "Czech (Czech Republic)"
                });
                languages.Add(new Language()
                {
                    LangCode = "cy-GB", LangName = "Welsh (United Kingdom)"
                });
                languages.Add(new Language()
                {
                    LangCode = "da-DK", LangName = "Danish (Denmark)"
                });
                languages.Add(new Language()
                {
                    LangCode = "de-AT", LangName = "German (Austria)"
                });
                languages.Add(new Language()
                {
                    LangCode = "de-CH", LangName = "German (Switzerland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "de-DE", LangName = "German (Germany)"
                });
                languages.Add(new Language()
                {
                    LangCode = "de-LI", LangName = "German (Liechtenstein)"
                });
                languages.Add(new Language()
                {
                    LangCode = "de-LU", LangName = "German (Luxembourg)"
                });
                languages.Add(new Language()
                {
                    LangCode = "dv-MV", LangName = "Divehi (Maldives)"
                });
                languages.Add(new Language()
                {
                    LangCode = "el-GR", LangName = "Greek (Greece)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-AU", LangName = "English (Australia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-BZ", LangName = "English (Belize)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-CA", LangName = "English (Canada)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-CB", LangName = "English (Caribbean)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-GB", LangName = "English (United Kingdom)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-IE", LangName = "English (Ireland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-JM", LangName = "English (Jamaica)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-NZ", LangName = "English (New Zealand)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-PH", LangName = "English (Republic of the Philippines)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-TT", LangName = "English (Trinidad and Tobago)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-US", LangName = "English (United States)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-ZA", LangName = "English (South Africa)"
                });
                languages.Add(new Language()
                {
                    LangCode = "en-ZW", LangName = "English (Zimbabwe)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-AR", LangName = "Spanish (Argentina)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-BO", LangName = "Spanish (Bolivia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-CL", LangName = "Spanish (Chile)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-CO", LangName = "Spanish (Colombia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-CR", LangName = "Spanish (Costa Rica)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-DO", LangName = "Spanish (Dominican Republic)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-EC", LangName = "Spanish (Ecuador)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-ES", LangName = "Spanish (Castilian)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-ES", LangName = "Spanish (Spain)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-GT", LangName = "Spanish (Guatemala)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-HN", LangName = "Spanish (Honduras)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-MX", LangName = "Spanish (Mexico)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-NI", LangName = "Spanish (Nicaragua)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-PA", LangName = "Spanish (Panama)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-PE", LangName = "Spanish (Peru)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-PR", LangName = "Spanish (Puerto Rico)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-PY", LangName = "Spanish (Paraguay)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-SV", LangName = "Spanish (El Salvador)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-UY", LangName = "Spanish (Uruguay)"
                });
                languages.Add(new Language()
                {
                    LangCode = "es-VE", LangName = "Spanish (Venezuela)"
                });
                languages.Add(new Language()
                {
                    LangCode = "et-EE", LangName = "Estonian (Estonia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "eu-ES", LangName = "Basque (Spain)"
                });
                languages.Add(new Language()
                {
                    LangCode = "fa-IR", LangName = "Farsi (Iran)"
                });
                languages.Add(new Language()
                {
                    LangCode = "fi-FI", LangName = "Finnish (Finland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "fo-FO", LangName = "Faroese (Faroe Islands)"
                });
                languages.Add(new Language()
                {
                    LangCode = "fr-BE", LangName = "French (Belgium)"
                });
                languages.Add(new Language()
                {
                    LangCode = "fr-CA", LangName = "French (Canada)"
                });
                languages.Add(new Language()
                {
                    LangCode = "fr-CH", LangName = "French (Switzerland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "fr-FR", LangName = "French (France)"
                });
                languages.Add(new Language()
                {
                    LangCode = "fr-LU", LangName = "French (Luxembourg)"
                });
                languages.Add(new Language()
                {
                    LangCode = "fr-MC", LangName = "French (Principality of Monaco)"
                });
                languages.Add(new Language()
                {
                    LangCode = "gl-ES", LangName = "Galician (Spain)"
                });
                languages.Add(new Language()
                {
                    LangCode = "gu-IN", LangName = "Gujarati (India)"
                });
                languages.Add(new Language()
                {
                    LangCode = "he-IL", LangName = "Hebrew (Israel)"
                });
                languages.Add(new Language()
                {
                    LangCode = "hi-IN", LangName = "Hindi (India)"
                });
                languages.Add(new Language()
                {
                    LangCode = "hr-BA", LangName = "Croatian (Bosnia and Herzegovina)"
                });
                languages.Add(new Language()
                {
                    LangCode = "hr-HR", LangName = "Croatian (Croatia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "hu-HU", LangName = "Hungarian (Hungary)"
                });
                languages.Add(new Language()
                {
                    LangCode = "hy-AM", LangName = "Armenian (Armenia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "id-ID", LangName = "Indonesian (Indonesia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "is-IS", LangName = "Icelandic (Iceland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "it-CH", LangName = "Italian (Switzerland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "it-IT", LangName = "Italian (Italy)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ja-JP", LangName = "Japanese (Japan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ka-GE", LangName = "Georgian (Georgia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "kk-KZ", LangName = "Kazakh (Kazakhstan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "kn-IN", LangName = "Kannada (India)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ko-KR", LangName = "Korean (Korea)"
                });
                languages.Add(new Language()
                {
                    LangCode = "kok-I", LangName = "Konkani (India)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ky-KG", LangName = "Kyrgyz (Kyrgyzstan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "lt-LT", LangName = "Lithuanian (Lithuania)"
                });
                languages.Add(new Language()
                {
                    LangCode = "lv-LV", LangName = "Latvian (Latvia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "mi-NZ", LangName = "Maori (New Zealand)"
                });
                languages.Add(new Language()
                {
                    LangCode = "mk-MK", LangName = "FYRO Macedonian (Former Yugoslav Republic of Macedonia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "mn-MN", LangName = "Mongolian (Mongolia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "mr-IN", LangName = "Marathi (India)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ms-BN", LangName = "Malay (Brunei Darussalam)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ms-MY", LangName = "Malay (Malaysia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "mt-MT", LangName = "Maltese (Malta)"
                });
                languages.Add(new Language()
                {
                    LangCode = "nb-NO", LangName = "Norwegian (Bokm?l) (Norway)"
                });
                languages.Add(new Language()
                {
                    LangCode = "nl-BE", LangName = "Dutch (Belgium)"
                });
                languages.Add(new Language()
                {
                    LangCode = "nl-NL", LangName = "Dutch (Netherlands)"
                });
                languages.Add(new Language()
                {
                    LangCode = "nn-NO", LangName = "Norwegian (Nynorsk) (Norway)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ns-ZA", LangName = "Northern Sotho (South Africa)"
                });
                languages.Add(new Language()
                {
                    LangCode = "pa-IN", LangName = "Punjabi (India)"
                });
                languages.Add(new Language()
                {
                    LangCode = "pl-PL", LangName = "Polish (Poland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ps-AR", LangName = "Pashto (Afghanistan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "pt-BR", LangName = "Portuguese (Brazil)"
                });
                languages.Add(new Language()
                {
                    LangCode = "pt-PT", LangName = "Portuguese (Portugal)"
                });
                languages.Add(new Language()
                {
                    LangCode = "qu-BO", LangName = "Quechua (Bolivia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "qu-EC", LangName = "Quechua (Ecuador)"
                });
                languages.Add(new Language()
                {
                    LangCode = "qu-PE", LangName = "Quechua (Peru)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ro-RO", LangName = "Romanian (Romania)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ru-RU", LangName = "Russian (Russia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sa-IN", LangName = "Sanskrit (India)"
                });
                languages.Add(new Language()
                {
                    LangCode = "se-FI", LangName = "Sami (Northern) (Finland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "se-FI", LangName = "Sami (Skolt) (Finland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "se-FI", LangName = "Sami (Inari) (Finland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "se-NO", LangName = "Sami (Northern) (Norway)"
                });
                languages.Add(new Language()
                {
                    LangCode = "se-NO", LangName = "Sami (Lule) (Norway)"
                });
                languages.Add(new Language()
                {
                    LangCode = "se-NO", LangName = "Sami (Southern) (Norway)"
                });
                languages.Add(new Language()
                {
                    LangCode = "se-SE", LangName = "Sami (Northern) (Sweden)"
                });
                languages.Add(new Language()
                {
                    LangCode = "se-SE", LangName = "Sami (Lule) (Sweden)"
                });
                languages.Add(new Language()
                {
                    LangCode = "se-SE", LangName = "Sami (Southern) (Sweden)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sk-SK", LangName = "Slovak (Slovakia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sl-SI", LangName = "Slovenian (Slovenia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sq-AL", LangName = "Albanian (Albania)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sr-BA", LangName = "Serbian (Latin) (Bosnia and Herzegovina)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sr-BA", LangName = "Serbian (Cyrillic) (Bosnia and Herzegovina)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sr-SP", LangName = "Serbian (Latin) (Serbia and Montenegro)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sr-SP", LangName = "Serbian (Cyrillic) (Serbia and Montenegro)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sv-FI", LangName = "Swedish (Finland)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sv-SE", LangName = "Swedish (Sweden)"
                });
                languages.Add(new Language()
                {
                    LangCode = "sw-KE", LangName = "Swahili (Kenya)"
                });
                languages.Add(new Language()
                {
                    LangCode = "syr-S", LangName = "Syriac (Syria)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ta-IN", LangName = "Tamil (India)"
                });
                languages.Add(new Language()
                {
                    LangCode = "te-IN", LangName = "Telugu (India)"
                });
                languages.Add(new Language()
                {
                    LangCode = "th-TH", LangName = "Thai (Thailand)"
                });
                languages.Add(new Language()
                {
                    LangCode = "tl-PH", LangName = "Tagalog (Philippines)"
                });
                languages.Add(new Language()
                {
                    LangCode = "tn-ZA", LangName = "Tswana (South Africa)"
                });
                languages.Add(new Language()
                {
                    LangCode = "tr-TR", LangName = "Turkish (Turkey)"
                });
                languages.Add(new Language()
                {
                    LangCode = "tt-RU", LangName = "Tatar (Russia)"
                });
                languages.Add(new Language()
                {
                    LangCode = "uk-UA", LangName = "Ukrainian (Ukraine)"
                });
                languages.Add(new Language()
                {
                    LangCode = "ur-PK", LangName = "Urdu (Islamic Republic of Pakistan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "uz-UZ", LangName = "Uzbek (Latin) (Uzbekistan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "uz-UZ", LangName = "Uzbek (Cyrillic) (Uzbekistan)"
                });
                languages.Add(new Language()
                {
                    LangCode = "vi-VN", LangName = "Vietnamese (Viet Nam)"
                });
                languages.Add(new Language()
                {
                    LangCode = "xh-ZA", LangName = "Xhosa (South Africa)"
                });
                languages.Add(new Language()
                {
                    LangCode = "zh-CN", LangName = "Chinese (S)"
                });
                languages.Add(new Language()
                {
                    LangCode = "zh-HK", LangName = "Chinese (Hong Kong)"
                });
                languages.Add(new Language()
                {
                    LangCode = "zh-MO", LangName = "Chinese (Macau)"
                });
                languages.Add(new Language()
                {
                    LangCode = "zh-SG", LangName = "Chinese (Singapore)"
                });
                languages.Add(new Language()
                {
                    LangCode = "zh-TW", LangName = "Chinese (T)"
                });
                languages.Add(new Language()
                {
                    LangCode = "zu-ZA", LangName = "Zulu (South Africa)"
                });

                context.SaveChanges();
            }
        }
Exemplo n.º 4
0
        public static Page <T> GetPage <T>(this Microsoft.EntityFrameworkCore.DbSet <T> list, int page_index, int page_size, Func <T, object> order_by_selector, bool descending = false, Func <T, bool> filter_by_predicate = null)
            where T : class
        {
            var res = list.OrderBy(order_by_selector)
                      .Skip(page_index * page_size)
                      .Take(page_size)
                      .ToArray();

            if (descending == true)
            {
                res = list.OrderByDescending(order_by_selector)
                      .Skip(page_index * page_size)
                      .Take(page_size)
                      .ToArray();
            }

            var tot_items = list.Count();

            if (descending == true)
            {
                if (filter_by_predicate != null)
                {
                    res = list.Where(filter_by_predicate)
                          .OrderByDescending(order_by_selector)
                          .Skip(page_index * page_size)
                          .Take(page_size)
                          .ToArray();

                    tot_items = list.Where(filter_by_predicate)
                                .Count();
                }
            }
            else
            {
                if (filter_by_predicate != null)
                {
                    res = list.Where(filter_by_predicate)
                          .OrderBy(order_by_selector)
                          .Skip(page_index * page_size)
                          .Take(page_size)
                          .ToArray();

                    tot_items = list.Where(filter_by_predicate)
                                .Count();
                }
            }

            if (res == null || res.Length == 0)
            {
                return(null);
            }


            var tot_pages = tot_items / page_size;

            if (tot_items < page_size)
            {
                tot_pages = 1;
            }

            return(new Page <T>()
            {
                index = page_index, items = res, totalPages = tot_pages
            });
        }