public void SaveCountry(CountryVM countryVM)
 {
     using (aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context = new aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context())
     {
         _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context.Country.Add(new Country()
         {
             Id = Guid.NewGuid().ToString(), Name = countryVM.country.Name
         });
         _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context.SaveChanges();
     }
 }
 public void SaveState(StateVM stateVM)
 {
     using (aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context = new aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context())
     {
         _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context.State.Add(new State()
         {
             Id = Guid.NewGuid().ToString(), Name = stateVM.state, CountryId = stateVM.selectedCountryId
         });
         _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context.SaveChanges();
     }
 }
        public IEnumerable <State> getStates()
        {
            List <State> states = new List <State>();

            using (aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context = new aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context())
            {
                foreach (State st in _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context.State.Where(rec => rec.CountryId == SelectedCountryId))
                {
                    states.Add(new State()
                    {
                        Id = st.Id, Name = st.Name, CountryId = st.CountryId
                    });
                }
            }
            return(states.AsEnumerable());
        }
        public IEnumerable <SelectListItem> getStatesAsSelectListItems()
        {
            List <SelectListItem> states = new List <SelectListItem>();

            using (aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context = new aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context())
            {
                foreach (State st in _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context.State.Where(rec => rec.CountryId == SelectedCountryId))
                {
                    states.Add(new SelectListItem()
                    {
                        Text = st.Name, Value = st.Id, Selected = (st.Id == SelectedStateId ? true : false)
                    });
                }
            }
            return(states.AsEnumerable());
        }
        public IEnumerable <Country> getCountries()
        {
            List <Country> countries = new List <Country>();

            using (aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context = new aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context())
            {
                foreach (Country cn in _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context.Country.Where(rec => rec.Id != ""))
                {
                    countries.Add(new Country()
                    {
                        Id = cn.Id, Name = cn.Name
                    });
                }
            }

            return(countries);
        }
        public IEnumerable <SelectListItem> getCountriesAsSelectListItems()
        {
            List <SelectListItem> countries = new List <SelectListItem>();

            using (aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context = new aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context())
            {
                foreach (Country cn in _aspnetCoreAuthenticationBE4FE1DC128845159E4A1B6F524F8DF7Context.Country)
                {
                    countries.Add(new SelectListItem()
                    {
                        Text = cn.Name, Value = cn.Id, Selected = (cn.Id == SelectedCountryId ? true : false)
                    });
                }
            }

            return(countries);
        }