Example #1
0
        //#region Update

        //private static void UpdateFieldsToTitleCaseAndUpperCase(Country entity)
        //{
        //    entity.Abbreviation = entity.Abbreviation.ToUpper();
        //    entity.Name = entity.Name.ToTitleCase();
        //}

        //#endregion

        //#region InitializationData and InitializationDataAsync

        //public void InitializationData()
        //{
        //    //get data
        //    string[,] countryDataArray = CountryData.CountryDataArray();
        //    if (!countryDataArray.IsNull() && countryDataArray.Length > 0)
        //    {
        //        for (int i = 0; i < countryDataArray.Length / 3; i++)
        //        {

        //            string countryName = countryDataArray[i, 0];
        //            string abbrev = countryDataArray[i, 1];

        //            Country c = Factory();
        //            c.Abbreviation = (abbrev.IsNull() ? abbrev : abbrev.ToUpper());
        //            c.Name = countryName;

        //            try
        //            {
        //                Create(c);
        //            }
        //            catch (NoDuplicateException e)
        //            {

        //                ErrorsGlobal.AddMessage(string.Format("Duplicate entry: '{0}'", c.ToString()), MethodBase.GetCurrentMethod(), e);
        //            }
        //        }
        //        SaveChanges();

        //    }

        //}

        //public async Task InitializationDataAsync()
        //{

        //    //get data
        //    string[,] countryDataArray = CountryData.CountryDataArray();
        //    if (!countryDataArray.IsNull() && countryDataArray.Length > 0)
        //    {
        //        for (int i = 0; i < countryDataArray.Length / 3; i++)
        //        {

        //            string countryName = countryDataArray[i, 0];
        //            string abbrev = countryDataArray[i, 1];
        //            string phoneAreaCode = countryDataArray[i, 2];

        //            Country c = Factory();
        //            c.Abbreviation = (abbrev.IsNull() ? abbrev : abbrev.ToUpper());
        //            c.Name = countryName;

        //            try
        //            {
        //                Create(c);
        //                await SaveChangesAsync();
        //            }
        //            catch (NoDuplicateException e)
        //            {

        //                ErrorsGlobal.AddMessage(string.Format("Duplicate entry: '{0}'", c.ToString()), MethodBase.GetCurrentMethod(), e);
        //            }
        //        }
        //    }

        //}

        //#endregion

        //#region FixIndexListVM and FixIndexListVMAsync

        //public override void GiveNamesToInputColumnsInIndexList(IndexListVM indexListVM)
        //{
        //    indexListVM.NameInput1 = "Abbreviation";
        //    indexListVM.NameInput2 = "Name";
        //    indexListVM.Heading_Column = "[Abbreviation] - Country Name ";


        //}
        //#endregion

        /// <summary>
        /// This loads the country Data into the select list
        /// </summary>
        /// <returns></returns>
        public override SelectList SelectList()
        {
            SelectList selectList = GetSelectListFromCache();

            if (selectList.IsNull())
            {
                //Load the data
                selectList = LoadDataIntoDbAndThenGetSelectListAndAddToCache();
            }
            return(selectList);
        }