예제 #1
0
        public ActionResult EditContact(int id, int contactId, AccountFilterModel filter)
        {
            var account = AccountServices.GetAccount(id);

            var model = new ContactDetailModel()
            {
                Action = "EditContact",
                Contact = account.ContactList.Where(c => c.Id == contactId).FirstOrDefault(),
                Filter = filter,
            };

            ViewBag.ContactTypes = AccountServices.GetContactTypes(model.Contact.ContactTypeId);

            return View("ContactDetail", model);
        }
예제 #2
0
        public ActionResult EditContact(int id, int contactId, AccountFilterModel filter, FormCollection collection)
        {
            var account = AccountServices.GetAccount(id);
            var contact = account.ContactList.Where(c => c.Id == contactId).FirstOrDefault();

            try
            {
                // Need to specify properties because the id (account) overwrites Contact.Id
                UpdateModel(contact, new string[] { "ContactTypeId", "ContactDetail", "FirstName", "LastName" });
                AccountServices.UpdateContact(account, contact);

                return RedirectToAction("EditAccount", filter.GenerateAccountDetailRoute(id));
            }
            catch (Exception ex)
            {
                // Invalid - redisplay with errors
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);

                var model = new ContactDetailModel()
                {
                    Action = "EditContact",
                    Contact = contact,
                    Filter = filter,
                };

                ViewBag.ContactTypes = AccountServices.GetContactTypes(contact.ContactTypeId);

                return View("ContactDetail", model);
            }
        }
예제 #3
0
        public ActionResult NewContact(int id, AccountFilterModel filter)
        {
            var account = AccountServices.GetAccount(id);

            var model = new ContactDetailModel()
            {
                Action = "NewContact",
                Contact = new ContactModel() { AccountId = id },
                Filter = filter,
            };

            ViewBag.ContactTypes = AccountServices.GetContactTypes(model.Contact.ContactTypeId);

            return View("ContactDetail", model);
        }