コード例 #1
0
        public void BindDDLs(PlaceView placeView, ObjectContext db)
        {
            //countries ddl
            ICountriesRepository countriesRepository = new CountriesRepository(db);

            placeView.Countries = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name");

            //counties ddl
            if (placeView.CountryFK != null)
            {
                ICountiesRepository countiesRepository = new CountiesRepository(db);
                placeView.Counties = new SelectList(countiesRepository.GetCountiesByCountry(Convert.ToInt32(placeView.CountryFK)).OrderBy("Name ASC"), "CountyPK", "Name");
            }
            else
            {
                placeView.Counties = new SelectList(new List <County>(), "CountyPK", "Name");
            }

            //postal offices ddl
            if (placeView.CountyFK != null)
            {
                IPostalOfficesRepository postalOfficesRepository = new PostalOfficesRepository(db);
                var postalOffices = postalOfficesRepository.GetValidByCounty(Convert.ToInt32(placeView.CountyFK)).OrderBy(c => c.Name);

                placeView.PostalOffices = new SelectList(postalOffices.Select(c => new { value = c.PostalOfficePK, text = c.Name + " (" + SqlFunctions.StringConvert((double)c.Number).Trim() + ")" }), "value", "text");
            }
            else
            {
                placeView.PostalOffices = new SelectList(new List <PostalOffice>(), "PostalOfficePK", "Name");
            }
        }
コード例 #2
0
 public void ConvertTo(PlaceView placeView, Place place)
 {
     place.PlacePK        = placeView.PlacePK;
     place.Name           = placeView.Name;
     place.Ordinal        = placeView.Ordinal;
     place.PostalOfficeFK = placeView.PostalOfficeFK;
     place.Deleted        = placeView.Deleted;
 }
コード例 #3
0
        public void ConvertFrom(Place place, PlaceView placeView, ObjectContext db)
        {
            placeView.PlacePK        = place.PlacePK;
            placeView.Name           = place.Name;
            placeView.Ordinal        = place.Ordinal;
            placeView.PostalOfficeFK = place.PostalOfficeFK;
            placeView.Deleted        = place.Deleted;

            //get county
            IPostalOfficesRepository postalOfficesRepository = new PostalOfficesRepository(db);

            placeView.CountyFK = (int)postalOfficesRepository.GetPostalOfficeByPK((int)placeView.PostalOfficeFK).CountyFK;

            //get country
            ICountiesRepository countiesRepository = new CountiesRepository(db);

            placeView.CountryFK = countiesRepository.GetCountyByPK((int)placeView.CountyFK).CountryFK;
        }