public StateProvince SaveInfo()
 {
     StateProvince stateProvince = this.StateProvinceService.GetStateProvinceById(this.StateProvinceId);
     if (stateProvince != null)
     {
         stateProvince.CountryId = int.Parse(this.ddlCountry.SelectedItem.Value);
         stateProvince.Name = txtName.Text;
         stateProvince.Abbreviation = txtAbbreviation.Text;
         stateProvince.DisplayOrder = txtDisplayOrder.Value;
         this.StateProvinceService.UpdateStateProvince(stateProvince);
     }
     else
     {
         stateProvince = new StateProvince()
         {
             CountryId = int.Parse(this.ddlCountry.SelectedItem.Value),
             Name = txtName.Text,
             Abbreviation = txtAbbreviation.Text,
             DisplayOrder = txtDisplayOrder.Value
         };
         this.StateProvinceService.InsertStateProvince(stateProvince);
     }
     return stateProvince;
 }
        /// <summary>
        /// Updates a state/province
        /// </summary>
        /// <param name="stateProvince">State/province</param>
        public void UpdateStateProvince(StateProvince stateProvince)
        {
            if (stateProvince == null)
                throw new ArgumentNullException("stateProvince");

            stateProvince.Name = CommonHelper.EnsureNotNull(stateProvince.Name);
            stateProvince.Name = CommonHelper.EnsureMaximumLength(stateProvince.Name, 100);
            stateProvince.Abbreviation = CommonHelper.EnsureNotNull(stateProvince.Abbreviation);
            stateProvince.Abbreviation = CommonHelper.EnsureMaximumLength(stateProvince.Abbreviation, 30);

            if (!_context.IsAttached(stateProvince))
                _context.StateProvinces.Attach(stateProvince);

            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(STATEPROVINCES_PATTERN_KEY);
            }
        }