public ActionResult Delete(int id) { ClientDetailESCInformation clientDetailESCInformation = new ClientDetailESCInformation(); clientDetailESCInformation = clientDetailESCInformationRepository.GetClientDetailESCInformation(id); //Check Exists if (clientDetailESCInformation == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailESCInformation.ClientDetailId; ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(id); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Check Exists if (clientAccount == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientAccountESCInformationVM clientAccountESCInformationVM = new ClientAccountESCInformationVM(); clientAccountESCInformationVM.ClientAccount = clientAccount; clientAccountESCInformationVM.ClientDetailESCInformation = clientDetailESCInformation; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientAccountESCInformationVM.ClientDetail = clientDetail; return(View(clientAccountESCInformationVM)); }
// GET: /View public ActionResult View(int id) { ClientDetailESCInformation clientDetailESCInformation = new ClientDetailESCInformation(); clientDetailESCInformation = clientDetailESCInformationRepository.GetClientDetailESCInformation(id); //Check Exists if (clientDetailESCInformation == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailESCInformation.ClientDetailId; ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(id); //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); //Check Exists if (clientAccount == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } ClientAccountESCInformationVM clientAccountESCInformationVM = new ClientAccountESCInformationVM(); clientAccountESCInformationVM.ClientAccount = clientAccount; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientAccountESCInformationVM.ClientDetail = clientDetail; clientAccountESCInformationVM.ClientDetailESCInformation = clientDetailESCInformation; return(View(clientAccountESCInformationVM)); }
// GET: /Create public ActionResult Create(int id) { ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(id); //Check Exists if (clientDetail == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(id); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Access Rights ViewData["Access"] = ""; RolesRepository rolesRepository = new RolesRepository(); if (rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Access"] = "WriteAccess"; } ClientAccountESCInformationVM clientAccountESCInformationVM = new ClientAccountESCInformationVM(); clientAccountESCInformationVM.ClientAccount = clientAccount; clientAccountESCInformationVM.ClientDetail = clientDetail; ClientDetailESCInformation clientDetailESCInformation = new ClientDetailESCInformation(); clientAccountESCInformationVM.ClientDetailESCInformation = clientDetailESCInformation; return(View(clientAccountESCInformationVM)); }
public ActionResult Edit(ClientAccountESCInformationVM clientAccountESCInformationVM) { int clientDetailId = clientAccountESCInformationVM.ClientDetailESCInformation.ClientDetailId; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); //Check Exists if (clientDetail == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(clientDetailId); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Check Exists if (clientAccount == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model from Form try { TryUpdateModel <ClientDetailESCInformation>(clientAccountESCInformationVM.ClientDetailESCInformation, "ClientDetailESCInformation"); } catch { string n = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { n += error.ErrorMessage; } } ViewData["Message"] = "ValidationError : " + n; return(View("Error")); } try { clientDetailESCInformationRepository.Edit(clientAccountESCInformationVM.ClientDetailESCInformation); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/ClientAccountESCInformation.mvc/Edit?id=" + clientDetailId; return(View("VersionError")); } LogRepository logRepository = new LogRepository(); logRepository.LogError(ex.Message); 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 })); }