Esempio n. 1
0
        /// <summary>
        /// Deletes a state/province
        /// </summary>
        /// <param name="stateProvince">The state/province</param>
        public virtual void DeleteZipcode(Zipcodes zipcodes)
        {
            if (zipcodes == null)
            {
                throw new ArgumentNullException("zipcodes");
            }

            _zipcodeRepository.Delete(zipcodes);

            _cacheManager.RemoveByPattern(ZIPCODE_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityDeleted(zipcodes);
        }
Esempio n. 2
0
        public List <Zipcodes> Checkaddress(int Zipcode)
        {
            List <Zipcodes> ZipcodesList = new List <Zipcodes>();

            try
            {
                command.Connection  = Connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "USP_GetAddressByZipcode";
                command.Parameters.Add(new SqlParameter("@Zipcode", Zipcode));
                DataAdapter = new SqlDataAdapter(command);
                _dataset    = new DataSet();
                DataAdapter.Fill(_dataset);
                if (_dataset.Tables[0] != null)
                {
                    if (_dataset.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in _dataset.Tables[0].Rows)
                        {
                            Zipcodes info = new Zipcodes();
                            info.Zipcode = dr["zipcode"].ToString();
                            info.City    = dr["City"].ToString();
                            info.State   = dr["state"].ToString();
                            info.County  = dr["county"].ToString();
                            ZipcodesList.Add(info);
                        }
                    }
                }
                return(ZipcodesList);
            }
            catch (Exception ex)
            {
                clsError.WriteException(ex);
                return(ZipcodesList);
            }
            finally
            {
                command.Dispose();
            }
        }
Esempio n. 3
0
        public ActionResult EditCity(CityModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCountries))
            {
                return(AccessDeniedView());
            }

            var cityname = _cityService.GetCity().Where(x => x.CityName == model.CityName && x.CityID != model.CityID).FirstOrDefault();

            if (cityname == null)
            {
                if (ModelState.IsValid)
                {
                    var city = model.ToEntity();
                    city.StateProvince = _stateProvinceService.GetStateProvinceById(city.StateID);
                    city.IsActive      = true;
                    city.IsDeleted     = false;
                    _cityService.UpdateCity(city);

                    //locales
                    UpdateLocales(city, model);


                    var zipcodess = _zipcodeService.GetZipcodesByCityId(model.CityID).ToList();

                    foreach (var z in zipcodess)
                    {
                        _zipcodeService.DeleteZipcode(z);
                    }

                    //zipcodes
                    string[] r = model.zipcodesbulk.Split(',');
                    foreach (string s in r)
                    {
                        if (s != "")
                        {
                            Zipcodes zip = new Zipcodes();
                            zip.StateID       = model.StateID;
                            zip.CityID        = city.CityID;
                            zip.IsActive      = true;
                            zip.IsDeleted     = false;
                            zip.ZipcodeNumber = s;
                            _zipcodeService.InsertzipCodes(zip);
                        }
                    }
                    //Stores
                    //SaveStoreMappings(city, model);

                    SuccessNotification(_localizationService.GetResource("Admin.Configuration.Zipcode.Added"));
                    return(continueEditing ? RedirectToAction("EditCity", new { id = city.CityID }) : RedirectToAction("CityList"));
                    //if (continueEditing)
                    //{
                    //    //selected tab
                    //    SaveSelectedTabIndex();

                    //    return RedirectToAction("Edit", new { id = country.Id });
                    //}

                    //return RedirectToAction("List");
                }
            }
            //If we got this far, something failed, redisplay form

            //Stores
            return(View(model));
        }
Esempio n. 4
0
        public ActionResult CreateCity(CityModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCountries))
            {
                return(AccessDeniedView());
            }

            var cityname = _cityService.GetCity().Where(x => x.CityName == model.CityName).FirstOrDefault();

            if (cityname == null)
            {
                if (ModelState.IsValid)
                {
                    var city = model.ToEntity();
                    city.StateProvince = _stateProvinceService.GetStateProvinceById(city.StateID);
                    city.IsActive      = true;
                    city.IsDeleted     = false;
                    _cityService.InsertCity(city);

                    //locales
                    UpdateLocales(city, model);

                    //zipcodes
                    string[] r = model.zipcodesbulk.Split(',');
                    foreach (string s in r)
                    {
                        if (s != "")
                        {
                            Zipcodes zip = new Zipcodes();
                            zip.StateID       = model.StateID;
                            zip.CityID        = city.CityID;
                            zip.IsActive      = true;
                            zip.IsDeleted     = false;
                            zip.ZipcodeNumber = s;
                            _zipcodeService.InsertzipCodes(zip);
                        }
                    }
                    //Stores
                    //SaveStoreMappings(city, model);

                    SuccessNotification(_localizationService.GetResource("Admin.Configuration.Zipcode.Added"));
                    return(continueEditing ? RedirectToAction("EditCity", new { id = city.Id }) : RedirectToAction("CityList"));
                }
            }
            //If we got this far, something failed, redisplay form

            //Stores
            //PrepareStoresMappingModel(model, null, true);
            model.Countries.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Address.SelectCountry"), Value = "0"
            });
            foreach (var c in _countryService.GetAllCountries(false))
            {
                model.Countries.Add(new SelectListItem {
                    Text = c.Name, Value = c.Id.ToString(), Selected = (c.Id == model.CountryId)
                });
            }
            model.States.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Address.SelectState"), Value = "0"
            });
            foreach (var c in _stateProvinceService.GetStateProvincesByCountryId(model.CountryId, true))
            {
                model.States.Add(new SelectListItem {
                    Text = c.Name, Value = c.Id.ToString(), Selected = (c.Id == model.StateID)
                });
            }
            return(View(model));
        }
Esempio n. 5
0
 public static Zipcodes ToEntity(this ZipcodeModel model, Zipcodes destination)
 {
     return model.MapTo(destination);
 }
Esempio n. 6
0
 public static ZipcodeModel ToModel(this Zipcodes entity)
 {
     return entity.MapTo<Zipcodes, ZipcodeModel>();
 }