public List<Country> GetCountry() { try { return HRMModel.Countries.ToList(); } catch (Exception) { throw; } } public List<State> GetStates(int countryId) { return (from s in HRMModel.States where s.CountryId == countryId select s).ToList(); } public List<EmployeeModel> GetCountry() { var countryModelList = new List<EmployeeModel>(); var countryList = dataAccess.GetCountry(); if (countryList != null && countryList.Count > 0) { foreach (var country in countryList) { var countryModel = new EmployeeModel(); countryModel.CountryId = country.CountryId; countryModel.CountryName = country.CountryName; countryModelList.Add(countryModel); } } return countryModelList; } //Form ModelLayer public List<EmployeeModel> GetStateOnId(int countryId) { var stateModelList = new List<EmployeeModel>(); var stateList = dataAccess.GetStates(countryId); foreach (var state in stateList) { var Model = new EmployeeModel(); Model.StateId = state.StateId; Model.StateName = state.StateName; stateModelList.Add(Model); } return stateModelList; } //From Cshtml code <pre lang="HTML"><pre lang="HTML">
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)