//Delete From DB public void Delete(ClientSubUnitTelephony clientSubUnitTelephony) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_DeleteClientSubUnitTelephony_v1( clientSubUnitTelephony.ClientSubUnitGuid, clientSubUnitTelephony.DialedNumber, adminUserGuid, clientSubUnitTelephony.VersionNumber ); }
//Add to DB public void Add(ClientSubUnitTelephony clientSubUnitTelephony) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_InsertClientSubUnitTelephony_v1( clientSubUnitTelephony.ClientSubUnitGuid, clientSubUnitTelephony.DialedNumber, clientSubUnitTelephony.CallerEnteredDigitDefinitionTypeId, adminUserGuid ); }
//Update in DB public void Update(ClientSubUnitTelephony clientSubUnitTelephony, string originalDialledNumber) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_UpdateClientSubUnitTelephony_v1( clientSubUnitTelephony.ClientSubUnitGuid, clientSubUnitTelephony.DialedNumber, originalDialledNumber, clientSubUnitTelephony.CallerEnteredDigitDefinitionTypeId, adminUserGuid, clientSubUnitTelephony.VersionNumber ); }
public ActionResult Delete(ClientSubUnitTelephonyVM clientSubUnitTelephonyVM) { //Get ClientSubUnitTelephony ClientSubUnitTelephony clientSubUnitTelephony = new ClientSubUnitTelephony(); clientSubUnitTelephony = clientSubUnitTelephonyRepository.GetClientSubUnitTelephony(clientSubUnitTelephonyVM.ClientSubUnitTelephony.ClientSubUnitGuid, clientSubUnitTelephonyVM.ClientSubUnitTelephony.DialedNumber); //Check Exists if (clientSubUnitTelephony == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnit(clientSubUnitTelephony.ClientSubUnitGuid)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Delete Item try { clientSubUnitTelephonyRepository.Delete(clientSubUnitTelephonyVM.ClientSubUnitTelephony); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/ClientSubUnitTelephony.mvc/Delete/id=" + clientSubUnitTelephony.ClientSubUnitGuid + "&dn=" + clientSubUnitTelephony.DialedNumber; 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 return(RedirectToAction("List", new { id = clientSubUnitTelephony.ClientSubUnitGuid })); }
// GET: /Edit public ActionResult Edit(string id, string dn) { //Get ClientSubUnitTelephony ClientSubUnitTelephony clientSubUnitTelephony = new ClientSubUnitTelephony(); clientSubUnitTelephony = clientSubUnitTelephonyRepository.GetClientSubUnitTelephony(id, dn); //Check Exists if (clientSubUnitTelephony == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnit(id)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientSubUnitTelephonyVM clientSubUnitTelephonyVM = new ClientSubUnitTelephonyVM(); clientSubUnitTelephonyVM.ClientSubUnitTelephony = clientSubUnitTelephony; //Get ClientSubUnit ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(id); clientSubUnitTelephonyVM.ClientSubUnit = clientSubUnit; //Identifier Drop-down CallerEnteredDigitDefinitionTypeRepository callerEnteredDigitDefinitionTypeRepository = new CallerEnteredDigitDefinitionTypeRepository(); clientSubUnitTelephonyVM.CallerEnteredDigitDefinitionTypes = new SelectList(callerEnteredDigitDefinitionTypeRepository.GetAllCallerEnteredDigitDefinitionTypes().ToList(), "CallerEnteredDigitDefinitionTypeId", "CallerEnteredDigitDefinitionTypeDescription", clientSubUnitTelephony.CallerEnteredDigitDefinitionTypeId); //Show Create Form return(View(clientSubUnitTelephonyVM)); }
public ActionResult Delete(string id, string dn) { //Get ClientSubUnitTelephony ClientSubUnitTelephony clientSubUnitTelephony = new ClientSubUnitTelephony(); clientSubUnitTelephony = clientSubUnitTelephonyRepository.GetClientSubUnitTelephony(id, dn); //Check Exists if (clientSubUnitTelephony == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnit(id)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientSubUnitTelephonyVM clientSubUnitTelephonyVM = new ClientSubUnitTelephonyVM(); clientSubUnitTelephonyVM.ClientSubUnitTelephony = clientSubUnitTelephony; //Get ClientSubUnit ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(id); clientSubUnitTelephonyVM.ClientSubUnit = clientSubUnit; //Show Form return(View(clientSubUnitTelephonyVM)); }
public ActionResult Create(ClientSubUnitTelephonyVM clientSubUnitTelephonyVM) { string clientSubUnitGuid = clientSubUnitTelephonyVM.ClientSubUnitTelephony.ClientSubUnitGuid; ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitGuid); //Check Exists if (clientSubUnit == null) { ViewData["ActionMethod"] = "CreatePost"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnit(clientSubUnitGuid)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientSubUnitTelephony clientSubUnitTelephony = new ClientSubUnitTelephony(); clientSubUnitTelephony = clientSubUnitTelephonyRepository.GetClientSubUnitTelephony(clientSubUnitGuid, clientSubUnitTelephonyVM.ClientSubUnitTelephony.DialedNumber); if (clientSubUnitTelephony != null) { ModelState.AddModelError("ClientSubUnitTelephony.DialedNumber", "This number already exists"); CallerEnteredDigitDefinitionTypeRepository callerEnteredDigitDefinitionTypeRepository = new CallerEnteredDigitDefinitionTypeRepository(); clientSubUnitTelephonyVM.CallerEnteredDigitDefinitionTypes = new SelectList(callerEnteredDigitDefinitionTypeRepository.GetAllCallerEnteredDigitDefinitionTypes().ToList(), "CallerEnteredDigitDefinitionTypeId", "CallerEnteredDigitDefinitionTypeDescription"); clientSubUnitTelephonyVM.ClientSubUnit = clientSubUnit; return(View(clientSubUnitTelephonyVM)); } //Update Model from Form try { UpdateModel <ClientSubUnitTelephony>(clientSubUnitTelephonyVM.ClientSubUnitTelephony, "ClientSubUnitTelephony"); } 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 { clientSubUnitTelephonyRepository.Add(clientSubUnitTelephonyVM.ClientSubUnitTelephony); } catch (SqlException ex) { 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 = clientSubUnitGuid })); }
public ClientSubUnitTelephonyVM(ClientSubUnitTelephony clientSubUnitTelephony, ClientSubUnit clientSubUnit, IEnumerable <SelectListItem> callerEnteredDigitDefinitionTypes) { ClientSubUnitTelephony = clientSubUnitTelephony; ClientSubUnit = clientSubUnit; CallerEnteredDigitDefinitionTypes = callerEnteredDigitDefinitionTypes; }