/// <summary> /// GET: /Company/{id}/Contact/{contactId}/Edit /// </summary> /// <param name="id"></param> /// <param name="contactId"></param> /// <returns></returns> public ActionResult Edit(int id, int? contactId) { if (contactId == null) { return View("Create"); } Contact contact = db.Contacts.Find(contactId); if (contact == null || contact.Company.Id != id) { return HttpNotFound(); } ContactVM model = new ContactVM(); model = model.contactToViewModel(contact); ModelState.Clear(); return View(model); }
/// <summary> /// GET: /Company/{id}/Contact/{contactId} /// </summary> /// <param name="id"></param> /// <param name="contactId"></param> /// <returns></returns> public ActionResult Details(int id, int? contactId) { ContactVM model = new ContactVM(); if (contactId == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Contact contact = db.Contacts.Find(contactId); if (contact == null || contact.Company.Id != id) { return HttpNotFound(); } model = model.contactToViewModel(contact); model.Addresses = GetAddresses((int)contactId); model.EmailAddresses = GetEmailAddresses((int)contactId); model.PhoneNumbers = GetPhoneNumbers((int)contactId); return View(model); }