Exemplo n.º 1
0
        public JsonResult GetProvinces(ConfigurationRequestViewModel viewModel)
        {
            var country = _addressConfigurationService.GetCountry(viewModel.CountryId);
            var city    = string.IsNullOrWhiteSpace(viewModel.CityName)
                ? _addressConfigurationService.GetCity(viewModel.CityId)
                : _addressConfigurationService.GetCity(viewModel.CityName);

            if (country == null)
            {
                // this is an error
            }
            else
            {
                // city may be null: that is handled in the service
                var provinces = _addressConfigurationService.GetAllProvinces(
                    viewModel.IsBillingAddress
                        ? AddressRecordType.BillingAddress
                        : AddressRecordType.ShippingAddress,
                    country, city);
                return(Json(new {
                    Success = true,
                    Provinces = provinces
                                .Select(tp =>
                                        new {
                        Value = tp.Record.TerritoryInternalRecord.Id,
                        Text = _contentManager.GetItemMetadata(tp).DisplayText
                    })
                                .OrderBy(obj => obj.Text)
                }));
            }
            // TODO
            return(Json(new List <string>()));
        }
Exemplo n.º 2
0
        public JsonResult GetCities(ConfigurationRequestViewModel viewModel)
        {
            var country = _addressConfigurationService.GetCountry(viewModel.CountryId);

            if (country == null)
            {
                // this is an error
            }
            else
            {
                var cities = _addressConfigurationService.GetAllCities(
                    viewModel.IsBillingAddress
                        ? AddressRecordType.BillingAddress
                        : AddressRecordType.ShippingAddress,
                    country);
                return(Json(new {
                    Success = true,
                    Cities = cities
                             .Select(tp =>
                                     new {
                        Value = tp.Record.TerritoryInternalRecord.Id,
                        Text = _contentManager.GetItemMetadata(tp).DisplayText
                    })
                             .OrderBy(obj => obj.Text)
                }));
            }
            // TODO
            return(Json(new List <string>()));
        }