Пример #1
0
        public async Task <ActionResult> ContactsCreate(ContactViewModel model)
        {
            if (ModelState.IsValid)
            {
                Contact contact = model.GetContact();

                try
                {
                    await contactRepository.CreateAsync(contact);
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e);
                }

                return(RedirectToAction("Contacts", "Customer", new { id = model.CustomerID }));
            }

            ViewBag.ContactTypeID = new SelectList(contactTypeRepository.ContactTypes(), "ContactTypeID", "Description", model.ContactTypeID);

            return(View(model));
        }