Exemple #1
0
        public ActionResult List()
        {
            PhonesService phonesService = new PhonesService();
            PhonesListVM  model         = new PhonesListVM();

            TryUpdateModel(model);

            if (!model.ContactID.HasValue || phonesService.GetContact(model.ContactID.Value) == null)
            {
                return(this.RedirectToAction <ContactsController>(c => c.List()));
            }

            model.Phones  = phonesService.GetAll().Where(p => p.ContactID == model.ContactID.Value).ToList();
            model.Contact = phonesService.GetContact(model.ContactID.Value);

            return(View(model));
        }
Exemple #2
0
        // INDEX

        public ActionResult Index(int?id)  //contactID
        {
            if (id != null)
            {
                Contact contact = GetUserContact(id.Value);

                if (contact != null)
                {
                    PhonesListVM model = new PhonesListVM()
                    {
                        Contact = contact
                    };

                    model.Entities = model.Contact.Phones;

                    return(View(model));
                }
            }

            return(HttpNotFound());
        }