Exemplo n.º 1
0
        protected AddressEditViewModel BuildViewModel(AddressPart part)
        {
            var viewModel = new AddressEditViewModel()
            {
                Address1    = part.Address1,
                Address2    = part.Address2,
                Address3    = part.Address3,
                AddressType = part.AddressType,
                PostalCode  = part.PostalCode
            };

            viewModel.Countries = _directoryService.GetCountries().Select(c => new SelectListItem()
            {
                Text = c.GetTitle(), Value = c.Id.ToString()
            }).ToList();
            // TODO: Seriously AJAX this
            viewModel.Towns = _directoryService.GetTowns().Select(c => new SelectListItem()
            {
                Text = c.GetTitle(), Value = c.Id.ToString()
            }).ToList();
            var town = _directoryService.GetTownForAddress(part);

            if (town != null)
            {
                viewModel.TownId   = town.Id;
                viewModel.TownName = town.As <ITitleAspect>().Title;
                var country = _directoryService.GetCountryForTown(town);
                if (country != null)
                {
                    viewModel.CountryId   = country.Id;
                    viewModel.CountryName = country.As <ITitleAspect>().Title;
                }
            }
            return(viewModel);
        }
Exemplo n.º 2
0
        public void ListRegions(string countryName = "")
        {
            IEnumerable <IContent> regions;

            if (String.IsNullOrWhiteSpace(countryName))
            {
                Context.Output.WriteLine("Listing all regions");
                regions = _directoryService.GetTowns();
            }
            else
            {
                var country = _directoryService.GetCountryByName(countryName);
                Context.Output.WriteLine("Listing regions in " + country.As <TitlePart>().Title);
                regions = _directoryService.GetTowns(country.Id);
            }
            foreach (var r in regions)
            {
                Context.Output.WriteLine(r.As <TitlePart>().Title);
            }
            Context.Output.WriteLine(regions.Count() + " regions");
        }
Exemplo n.º 3
0
        protected AddressEditViewModel BuildCreateModel()
        {
            var viewModel = new AddressEditViewModel()
            {
/*                Address1 = part.Address1,
 *              Address2 = part.Address2,
 *              Address3 = part.Address3,
 *              AddressType = part.AddressType,
 *              PostalCode = part.PostalCode*/
            };

            viewModel.Countries = _directoryService.GetCountries().Select(c => new SelectListItem()
            {
                Text = c.GetTitle(), Value = c.Id.ToString()
            }).ToList();
            // TODO: Seriously AJAX this
            viewModel.Towns = _directoryService.GetTowns().Select(c => new SelectListItem()
            {
                Text = c.GetTitle(), Value = c.Id.ToString()
            }).ToList();

            return(viewModel);
        }