public ActionResult Delete(int id) { ClientDetailContact clientDetailContact = new ClientDetailContact(); clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id); //Check Exists if (clientDetailContact == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailContact.ClientDetailId; ClientDetailClientTopUnit clientDetailClientTopUnit = new ClientDetailClientTopUnit(); clientDetailClientTopUnit = clientDetailClientTopUnitRepository.GetClientDetailClientTopUnit(clientDetailId); //Check Exists if (clientDetailClientTopUnit == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } string clientTopUnitGuid = clientDetailClientTopUnit.ClientTopUnitGuid; ClientTopUnit clientTopUnit = new ClientTopUnit(); clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientTopUnitGuid); //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientTopUnit(clientTopUnitGuid)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientTopUnitContactVM clientTopUnitContactVM = new ClientTopUnitContactVM(); clientTopUnitContactVM.ClientTopUnit = clientTopUnit; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientTopUnitContactVM.ClientDetail = clientDetail; Contact contact = new Contact(); contact = contactRepository.GetContact(clientDetailContact.ContactId); contactRepository.EditForDisplay(contact); clientTopUnitContactVM.Contact = contact; return(View(clientTopUnitContactVM)); }
// GET: /View public ActionResult View(int id) { ClientDetailContact clientDetailContact = new ClientDetailContact(); clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id); //Check Exists if (clientDetailContact == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailContact.ClientDetailId; ClientDetailClientSubUnitTravelerType clientDetailClientSubUnitTravelerType = new ClientDetailClientSubUnitTravelerType(); clientDetailClientSubUnitTravelerType = clientDetailClientSubUnitTravelerTypeRepository.GetClientDetailClientSubUnitTravelerType(clientDetailId); //Check Exists if (clientDetailClientSubUnitTravelerType == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } string csu = clientDetailClientSubUnitTravelerType.ClientSubUnitGuid; string tt = clientDetailClientSubUnitTravelerType.TravelerTypeGuid; ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); ClientSubUnitTravelerTypeContactVM clientSubUnitTravelerTypeContactVM = new ClientSubUnitTravelerTypeContactVM(); clientSubUnitTravelerTypeContactVM.ClientSubUnit = clientSubUnit; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientSubUnitTravelerTypeContactVM.ClientDetail = clientDetail; TravelerType travelerType = new TravelerType(); travelerType = travelerTypeRepository.GetTravelerType(tt); clientSubUnitTravelerTypeContactVM.TravelerType = travelerType; Contact contact = new Contact(); contact = contactRepository.GetContact(clientDetailContact.ContactId); contactRepository.EditForDisplay(contact); clientSubUnitTravelerTypeContactVM.Contact = contact; return(View(clientSubUnitTravelerTypeContactVM)); }
// GET: /View public ActionResult View(int id) { ClientDetailContact clientDetailContact = new ClientDetailContact(); clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id); //Check Exists if (clientDetailContact == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailContact.ClientDetailId; ClientDetailClientTopUnit clientDetailClientTopUnit = new ClientDetailClientTopUnit(); clientDetailClientTopUnit = clientDetailClientTopUnitRepository.GetClientDetailClientTopUnit(clientDetailId); //Check Exists if (clientDetailClientTopUnit == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } string clientTopUnitGuid = clientDetailClientTopUnit.ClientTopUnitGuid; ClientTopUnit clientTopUnit = new ClientTopUnit(); clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientTopUnitGuid); ClientTopUnitContactVM clientTopUnitContactVM = new ClientTopUnitContactVM(); clientTopUnitContactVM.ClientTopUnit = clientTopUnit; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientTopUnitContactVM.ClientDetail = clientDetail; Contact contact = new Contact(); contact = contactRepository.GetContact(clientDetailContact.ContactId); contactRepository.EditForDisplay(contact); clientTopUnitContactVM.Contact = contact; return(View(clientTopUnitContactVM)); }
// GET: /View public ActionResult View(int id) { ClientDetailContact clientDetailContact = new ClientDetailContact(); clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id); //Check Exists if (clientDetailContact == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailContact.ClientDetailId; ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(clientDetailId); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); ClientAccountContactVM clientAccountContactVM = new ClientAccountContactVM(); clientAccountContactVM.ClientAccount = clientAccount; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientAccountContactVM.ClientDetail = clientDetail; Contact contact = new Contact(); contact = contactRepository.GetContact(clientDetailContact.ContactId); contactRepository.EditForDisplay(contact); clientAccountContactVM.Contact = contact; return(View(clientAccountContactVM)); }
public ActionResult Delete(int id, FormCollection collection) { ClientDetailContact clientDetailContact = new ClientDetailContact(); clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id); //Check Exists if (clientDetailContact == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailContact.ClientDetailId; ClientDetailClientTopUnit clientDetailClientTopUnit = new ClientDetailClientTopUnit(); clientDetailClientTopUnit = clientDetailClientTopUnitRepository.GetClientDetailClientTopUnit(clientDetailId); //Check Exists if (clientDetailClientTopUnit == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } string clientTopUnitGuid = clientDetailClientTopUnit.ClientTopUnitGuid; ClientTopUnit clientTopUnit = new ClientTopUnit(); clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientTopUnitGuid); //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientTopUnit(clientTopUnitGuid)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } Contact contact = new Contact(); contact = contactRepository.GetContact(id); //Delete Item try { contact.VersionNumber = Int32.Parse(collection["Contact.VersionNumber"]); contactRepository.Delete(contact); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/ClientTopUnitContact.mvc/Delete/" + id.ToString(); return(View("VersionError")); } //Generic Error ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } return(RedirectToAction("List", new { id = clientDetailId })); }
// GET: /View public ActionResult View(string csu, int id) { ClientDetailContact clientDetailContact = new ClientDetailContact(); clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id); //Check Exists if (clientDetailContact == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailContact.ClientDetailId; ClientDetailTravelerType clientDetailTravelerType = new ClientDetailTravelerType(); clientDetailTravelerType = clientDetailTravelerTypeRepository.GetClientDetailTravelerType(clientDetailId); //Check Exists if (clientDetailTravelerType == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } string tt = clientDetailTravelerType.TravelerTypeGuid; ClientSubUnitTravelerType clientSubUnitTravelerType = new ClientSubUnitTravelerType(); clientSubUnitTravelerType = clientSubUnitTravelerTypeRepository.GetClientSubUnitTravelerType(csu, tt); //Check Exists if (clientSubUnitTravelerType == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnit(csu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } TravelerTypeContactVM travelerTypeContactVM = new TravelerTypeContactVM(); ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); travelerTypeContactVM.ClientSubUnit = clientSubUnit; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); travelerTypeContactVM.ClientDetail = clientDetail; TravelerType travelerType = new TravelerType(); travelerType = travelerTypeRepository.GetTravelerType(tt); travelerTypeContactVM.TravelerType = travelerType; Contact contact = new Contact(); contact = contactRepository.GetContact(clientDetailContact.ContactId); contactRepository.EditForDisplay(contact); travelerTypeContactVM.Contact = contact; return(View(travelerTypeContactVM)); }
// GET: /Edit public ActionResult Edit(int id) { ClientDetailContact clientDetailContact = new ClientDetailContact(); clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id); //Check Exists if (clientDetailContact == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailContact.ClientDetailId; ClientDetailClientSubUnitTravelerType clientDetailClientSubUnitTravelerType = new ClientDetailClientSubUnitTravelerType(); clientDetailClientSubUnitTravelerType = clientDetailClientSubUnitTravelerTypeRepository.GetClientDetailClientSubUnitTravelerType(clientDetailId); //Check Exists if (clientDetailClientSubUnitTravelerType == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } string csu = clientDetailClientSubUnitTravelerType.ClientSubUnitGuid; string tt = clientDetailClientSubUnitTravelerType.TravelerTypeGuid; ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnit(csu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientSubUnitTravelerTypeContactVM clientSubUnitTravelerTypeContactVM = new ClientSubUnitTravelerTypeContactVM(); clientSubUnitTravelerTypeContactVM.ClientSubUnit = clientSubUnit; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientSubUnitTravelerTypeContactVM.ClientDetail = clientDetail; TravelerType travelerType = new TravelerType(); travelerType = travelerTypeRepository.GetTravelerType(tt); clientSubUnitTravelerTypeContactVM.TravelerType = travelerType; Contact contact = new Contact(); contact = contactRepository.GetContact(clientDetailContact.ContactId); clientSubUnitTravelerTypeContactVM.Contact = contact; ContactTypeRepository contactTypeRepository = new ContactTypeRepository(); clientSubUnitTravelerTypeContactVM.ContactTypes = new SelectList(contactTypeRepository.GetAllContactTypes().ToList(), "ContactTypeId", "ContactTypeName", contact.ContactTypeId); return(View(clientSubUnitTravelerTypeContactVM)); }
// GET: /Edit public ActionResult Edit(int id) { ClientDetailContact clientDetailContact = new ClientDetailContact(); clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id); //Check Exists if (clientDetailContact == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailContact.ClientDetailId; ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(clientDetailId); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientAccountContactVM clientAccountContactVM = new ClientAccountContactVM(); clientAccountContactVM.ClientAccount = clientAccount; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientAccountContactVM.ClientDetail = clientDetail; Contact contact = new Contact(); contact = contactRepository.GetContact(clientDetailContact.ContactId); clientAccountContactVM.Contact = contact; ContactTypeRepository contactTypeRepository = new ContactTypeRepository(); clientAccountContactVM.ContactTypes = new SelectList(contactTypeRepository.GetAllContactTypes().ToList(), "ContactTypeId", "ContactTypeName", contact.ContactTypeId); return(View(clientAccountContactVM)); }