Example #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);
        }
Example #2
0
        public void ListCountries()
        {
            var countries = _directoryService.GetCountries();

            foreach (var c in countries)
            {
                Context.Output.WriteLine(c.As <TitlePart>().Title); // + " ("+c.CountryCode+")");
            }
            Context.Output.WriteLine(countries.Count() + " countries");
        }
Example #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);
        }