public ActionResult Index()
        {
            IEnumerable <Person> persons   = _personHandler.GetAllPersons();
            List <PersonTdVM>    personVMs = new List <PersonTdVM>();

            foreach (Person person in persons)
            {
                personVMs.Add(new PersonTdVM
                {
                    Person             = person as Person,
                    AddressCount       = person.Addresses.Count(),
                    AddressTitleString = String.Join("; ", person.Addresses.Select(a => a.Street))
                });
            }

            return(View(personVMs));
        }
Пример #2
0
        public ActionResult Index()
        {
            IEnumerable <Person> persons = _personHandler.GetAllPersons();

            // The controller is responsible for populating the ViewModel.
            // This is synonyous to the MVVM pattern. Note that the view is strongly typed.
            List <PersonListVM> personVMs = new List <PersonListVM>();

            foreach (Person person in persons)
            {
                personVMs.Add(new PersonListVM
                {
                    Person       = person as Person,
                    AddressCount = person.Addresses.Count()
                });
            }

            return(View(personVMs));
        }