public void ConvertTo(PostalOfficeView postalOfficeView, PostalOffice postalOffice) { postalOffice.PostalOfficePK = postalOfficeView.PostalOfficePK; postalOffice.Name = postalOfficeView.Name; postalOffice.CountyFK = postalOfficeView.CountyFK; postalOffice.Number = postalOfficeView.Number; }
public void ConvertFrom(PostalOffice postalOffice, PostalOfficeView postalOfficeView, ObjectContext db) { postalOfficeView.PostalOfficePK = postalOffice.PostalOfficePK; postalOfficeView.Name = postalOffice.Name; postalOfficeView.CountyFK = postalOffice.CountyFK; postalOfficeView.Number = postalOffice.Number; postalOfficeView.Deleted = postalOffice.Deleted; //get country id ICountiesRepository countiesRepository = new CountiesRepository(db); postalOfficeView.CountryFK = countiesRepository.GetCountyByPK((int)postalOfficeView.CountyFK).CountryFK; }
public void BindDDLs(PostalOfficeView postalOfficeView, ObjectContext db) { //countries ddl ICountriesRepository countriesRepository = new CountriesRepository(db); postalOfficeView.Countries = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name"); //counties ddl if (postalOfficeView.CountryFK != null) { ICountiesRepository countiesRepository = new CountiesRepository(db); postalOfficeView.Counties = new SelectList(countiesRepository.GetCountiesByCountry(Convert.ToInt32((int)postalOfficeView.CountryFK)), "CountyPK", "Name"); } else { postalOfficeView.Counties = new SelectList(new List <County>(), "CountyPK", "Name"); } }