//Get CreditCard Behavior (Editable and Are Real Numbers Allowed public CreditCardBehavior GetCreditCardBehavior() { string databaseConnectionName = Settings.getConnectionString(); DbConnectionStringBuilder builder = new DbConnectionStringBuilder(); builder.ConnectionString = databaseConnectionName; string databaseName = builder["Initial Catalog"] as string; var result = (from n in db.spDesktopDataAdmin_SelectCreditCardBehaviour_v1(databaseName) select new CreditCardBehavior { CanHaveRealCreditCardsFlag = n.CanHaveRealCreditCardsFlag, CanChangeCreditCardsFlag = n.CanChangeCreditCardsFlag }).ToList(); if (result != null) { return(result.FirstOrDefault()); } else { CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior.CanChangeCreditCardsFlag = false; creditCardBehavior.CanHaveRealCreditCardsFlag = false; return(creditCardBehavior); } }
public ActionResult Delete(int id, string can, string ssc, string csu) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "DeleteGet"; return(View("Error")); } ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Check Exists if (clientAccount == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(id, false); //Check Exists if (creditCard == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); //Check Exists if (clientSubUnit == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } creditCard.ClientAccountName = clientAccount.ClientAccountName; creditCard.ClientAccountNumber = clientAccount.ClientAccountNumber; creditCard.SourceSystemCode = clientAccount.SourceSystemCode; creditCard.ClientSubUnitName = clientSubUnit.ClientSubUnitName; //Log View Of Credit Card LogRepository logRepository = new LogRepository(); logRepository.LogApplicationUsage(8, clientSubUnit.ClientSubUnitGuid, "", "", creditCard.CreditCardToken, creditCard.CreditCardTypeId, true); creditCardRepository.EditForDisplay(creditCard); return(View(creditCard)); }
public ActionResult Delete(int id, FormCollection collection) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "DeletePost"; return(View("Error")); } //Check Exists CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(id, false); if (creditCard == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } string ctu = creditCard.ClientTopUnitGuid; //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientTopUnitCreditCards(ctu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Database Update try { creditCard.VersionNumber = Int32.Parse(collection["CreditCard.VersionNumber"]); creditCardClientTopUnitRepository.Delete(creditCard); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/CreditCardClientTopUnit.mvc/Delete?id=" + id + "&ctu=" + ctu; 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 = ctu })); }
public ClientTopUnitCreditCardsVM( ClientTopUnit clientTopUnit, CreditCardBehavior creditCardBehavior, CWTPaginatedList <spDesktopDataAdmin_SelectClientTopUnitCreditCards_v1Result> creditCards ) { ClientTopUnit = clientTopUnit; CreditCardBehavior = creditCardBehavior; CreditCards = creditCards; }
public ActionResult Delete(int id, string ctu) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "DeleteGet"; return(View("Error")); } //Check Exists CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(id, false); creditCard.ValidateCreditCardNumber = true; if (creditCard == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientTopUnitCreditCards(ctu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientTopUnitCreditCardVM clientTopUnitCreditCardVM = new ClientTopUnitCreditCardVM(); clientTopUnitCreditCardVM.ClientTopUnit = clientTopUnitRepository.GetClientTopUnit(ctu); creditCardRepository.EditForDisplay(creditCard); clientTopUnitCreditCardVM.CreditCard = creditCard; CreditCardTypeRepository creditCardTypeRepository = new CreditCardTypeRepository(); clientTopUnitCreditCardVM.CreditCardTypes = new SelectList(creditCardTypeRepository.GetAllCreditCardTypes().ToList(), "CreditCardTypeId", "CreditCardTypeDescription", creditCard.CreditCardTypeId); CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository(); clientTopUnitCreditCardVM.CreditCardVendors = new SelectList(creditCardVendorRepository.GetAllCreditCardVendors().ToList(), "CreditCardVendorCode", "CreditCardVendorName", creditCard.CreditCardVendorCode); //Log View Of Credit Card LogRepository logRepository = new LogRepository(); logRepository.LogApplicationUsage(8, "", "", "", creditCard.CreditCardToken, creditCard.CreditCardTypeId, true); //Show View Form return(View(clientTopUnitCreditCardVM)); }
public ActionResult Delete(int id, FormCollection collection) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "DeletePost"; return(View("Error")); } //Get Item From Database CreditCard group = new CreditCard(); group = creditCardRepository.GetCreditCard(id, false); //Check Exists if (group == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Check Access //RolesRepository rolesRepository = new RolesRepository(); //if (!rolesRepository.HasWriteAccessToPolicyGroup(id)) // { // ViewData["Message"] = "You do not have access to this item"; // return View("Error"); //} //Delete Item try { group.VersionNumber = Int32.Parse(collection["VersionNumber"]); creditCardRepository.DeleteCWTCreditCard(group); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/CWTCreditCard.mvc/Delete/" + id.ToString(); 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")); }
public TravelerTypeCreditCardsVM( ClientTopUnit clientTopUnit, ClientSubUnit clientSubUnit, TravelerType travelerType, CreditCardBehavior creditCardBehavior, CWTPaginatedList <spDesktopDataAdmin_SelectTravelerTypeCreditCards_v1Result> creditCards ) { ClientTopUnit = clientTopUnit; ClientSubUnit = clientSubUnit; TravelerType = travelerType; CreditCardBehavior = creditCardBehavior; CreditCards = creditCards; }
//// GET: /Create //public ActionResult Create() //{ // //Check Access Rights to Domain // if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) // { // ViewData["Message"] = "You do not have access to this item"; // return View("Error"); // } // CreditCardTypeRepository creditCardTypeRepository = new CreditCardTypeRepository(); // ViewData["CreditCardTypeList"] = new SelectList(creditCardTypeRepository.GetAllCreditCardTypes().ToList(), "CreditCardTypeId", "CreditCardTypeDescription"); // CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository(); // SelectList creditCardVendorsList = new SelectList(creditCardVendorRepository.GetAllCreditCardVendors().ToList(), "CreditCardVendorCode", "CreditCardVendorName"); // ViewData["CreditCardVendors"] = creditCardVendorsList; // TablesDomainHierarchyLevelRepository tablesDomainHierarchyLevelRepository = new TablesDomainHierarchyLevelRepository(); // SelectList hierarchyTypesList = new SelectList(tablesDomainHierarchyLevelRepository.GetDomainHierarchies(groupName).ToList(), "HierarchyLevelTableName", "HierarchyLevelTableName"); // ViewData["HierarchyTypes"] = hierarchyTypesList; // CreditCard creditCard = new CreditCard(); // creditCard.CanHaveRealCreditCardsFlag = creditCardRepository.GetCreditCardBehavior().CanHaveRealCreditCardsFlag; // creditCard.WarningShownFlag = !creditCard.CanHaveRealCreditCardsFlag; // return View(creditCard); //} //// POST: /Create //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Create(CreditCard group) //{ // //Check Access Rights to Domain // if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) // { // ViewData["Message"] = "You do not have access to this item"; // return View("Error"); // } // //Check Access Rights to Domain Hierarchy // //if (!hierarchyRepository.AdminHasDomainHierarchyWriteAccess(group.HierarchyType, group.HierarchyCode, group.SourceSystemCode, groupName)) // //{ // // ViewData["Message"] = "You cannot add to this hierarchy item"; // // return View("Error"); // //} // //Update Model From Form + Validate against DB // try // { // UpdateModel(group); // } // 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"); // } // //ClientSubUnitTravelerType has extra field // string hierarchyCode = group.HierarchyCode; // if (group.HierarchyType == "ClientSubUnitTravelerType") // { // group.ClientSubUnitGuid = hierarchyCode; //ClientSubUnitTravelerType has 2 primarykeys // } // //Database Update // try // { // creditCardRepository.AddCWTCreditCard(group); // } // 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"); //} //GET: /Edit public ActionResult Edit(int id) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "EditGet"; return(View("Error")); } //Get Item From Database CreditCard group = new CreditCard(); group = creditCardRepository.GetCreditCard(id, true); //Check Exists if (group == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check Access //RolesRepository rolesRepository = new RolesRepository(); // (!rolesRepository.HasWriteAccessToPolicyGroup(id)) //{ // ViewData["Message"] = "You do not have access to this item"; // return View("Error"); //} CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository(); SelectList creditCardVendorsList = new SelectList(creditCardVendorRepository.GetAllCreditCardVendors().ToList(), "CreditCardVendorCode", "CreditCardVendorName"); ViewData["CreditCardVendors"] = creditCardVendorsList; TablesDomainHierarchyLevelRepository tablesDomainHierarchyLevelRepository = new TablesDomainHierarchyLevelRepository(); SelectList hierarchyTypesList = new SelectList(tablesDomainHierarchyLevelRepository.GetDomainHierarchies(groupName).ToList(), "HierarchyLevelTableName", "HierarchyLevelTableName"); ViewData["HierarchyTypes"] = hierarchyTypesList; //Log View Of Credit Card LogRepository logRepository = new LogRepository(); logRepository.LogApplicationUsage(8, "", "", "", group.CreditCardToken, group.CreditCardTypeId, true); creditCardRepository.EditForDisplay(group); return(View(group)); }
public ActionResult Delete(int id) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "DeleteGet"; return(View("Error")); } //Check Exists CreditCardClientSubUnitTravelerType creditCardClientSubUnitTravelerType = new CreditCardClientSubUnitTravelerType(); creditCardClientSubUnitTravelerType = creditCardClientSubUnitTravelerTypeRepository.GetCreditCardClientSubUnitTravelerType(id); if (creditCardClientSubUnitTravelerType == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } string csu = creditCardClientSubUnitTravelerType.ClientSubUnitGuid; string tt = creditCardClientSubUnitTravelerType.TravelerTypeGuid; ClientSubUnitTravelerTypeCreditCardVM clientSubUnitTravelerTypeCreditCardVM = new ClientSubUnitTravelerTypeCreditCardVM(); clientSubUnitTravelerTypeCreditCardVM.TravelerType = travelerTypeRepository.GetTravelerType(tt); clientSubUnitTravelerTypeCreditCardVM.ClientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(id, false); creditCardRepository.EditForDisplay(creditCard); clientSubUnitTravelerTypeCreditCardVM.CreditCard = creditCard; //Log View Of Credit Card LogRepository logRepository = new LogRepository(); logRepository.LogApplicationUsage(8, csu, tt, "", creditCard.CreditCardToken, creditCard.CreditCardTypeId, true); return(View(clientSubUnitTravelerTypeCreditCardVM)); }
public ActionResult Delete(int id) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "DeleteGet"; return(View("Error")); } CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(id, false); //Check Exists if (creditCard == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check Exists CreditCardClientSubUnit creditCardClientSubUnit = new CreditCardClientSubUnit(); creditCardClientSubUnit = creditCardClientSubUnitRepository.GetCreditCardClientSubUnit(id); if (creditCardClientSubUnit == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Log View Of Credit Card LogRepository logRepository = new LogRepository(); logRepository.LogApplicationUsage(8, creditCardClientSubUnit.ClientSubUnitGuid, "", "", creditCard.CreditCardToken, creditCard.CreditCardTypeId, true); creditCardRepository.EditForDisplay(creditCard); return(View(creditCard)); }
public ActionResult Delete(int id) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "DeleteGet"; return(View("Error")); } //Get Item CreditCard group = new CreditCard(); group = creditCardRepository.GetCreditCard(id, false); //Check Exists if (group == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check Access // RolesRepository rolesRepository = new RolesRepository(); //if (!rolesRepository.HasWriteAccessToPolicyGroup(id)) //{ // ViewData["Message"] = "You do not have access to this item"; // return View("Error"); //} //Log View Of Credit Card LogRepository logRepository = new LogRepository(); logRepository.LogApplicationUsage(8, "", "", "", group.CreditCardToken, group.CreditCardTypeId, true); creditCardRepository.EditForDisplay(group); return(View(group)); }
public ActionResult Delete(int id, string can, string ssc, string csu, FormCollection collection) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "DeletePost"; return(View("Error")); } ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Check Exists if (clientAccount == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); //Check Exists if (clientSubUnit == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Get Item CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(id, false); //Check Exists if (creditCard == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientAccountCreditCards(can, ssc)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Delete Item try { creditCard.ClientSubUnitGuid = csu; creditCard.VersionNumber = Int32.Parse(collection["VersionNumber"]); creditCardClientAccountRepository.Delete(creditCard); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/CreditCardClientAccount.mvc/Delete?id=" + id.ToString() + "&can=" + can + "&ssc=" + ssc; 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 { can = can, ssc = ssc, csu = csu })); }
public ActionResult Edit(int id, FormCollection collection) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "EditPost"; return(View("Error")); } //Get Item From Database CreditCardEditable creditCard = new CreditCardEditable(); creditCard = creditCardRepository.GetCreditCardEditable(id, false); //Check Exists if (creditCard == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } //Check Access //RolesRepository rolesRepository = new RolesRepository(); //if (!rolesRepository.HasWriteAccessToPolicyGroup(id)) //{ // ViewData["Message"] = "You do not have access to this item"; // return View("Error"); //} //Update Model From Form + Validate against DB try { UpdateModel(creditCard); } 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")); } //ClientSubUnitTravelerType has extra field string hierarchyCode = creditCard.HierarchyCode; if (creditCard.HierarchyType == "ClientSubUnitTravelerType") { creditCard.ClientSubUnitGuid = hierarchyCode; //ClientSubUnitTravelerType has 2 primarykeys } //Check Access Rights HierarchyRepository hierarchyRepository = new HierarchyRepository(); if (!hierarchyRepository.AdminHasDomainHierarchyWriteAccess(creditCard.HierarchyType, hierarchyCode, creditCard.SourceSystemCode, groupName)) { ViewData["Message"] = "You cannot add to this hierarchy item"; return(View("Error")); } //Database Update try { creditCard.VersionNumber = Int32.Parse(collection["VersionNumber"]); creditCardRepository.EditCWTCreditCard(creditCard, collection["OriginalCreditCardNumber"]); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/CWTCreditCard.mvc/Edit/" + creditCard.CreditCardId.ToString(); 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")); }
public ActionResult Edit(int id, string can, string ssc, string csu, FormCollection collection) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "EditPost"; return(View("Error")); } //Get Item From Database CreditCardEditable creditCard = new CreditCardEditable(); creditCard = creditCardRepository.GetCreditCardEditable(id, false); //Check Exists if (creditCard == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); //Check Exists if (clientSubUnit == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientAccountCreditCards(can, ssc)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model From Form + Validate against DB try { UpdateModel(creditCard); } 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")); } //Database Update try { creditCard.ClientSubUnitGuid = csu; creditCard.VersionNumber = Int32.Parse(collection["VersionNumber"]); creditCardRepository.Edit(creditCard); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/CreditCardClientAccount.mvc/Edit?id=" + id + "&can=" + can + "&ssc=" + ssc; 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 { can = can, ssc = ssc, csu = csu })); }
// GET: /Edit public ActionResult Edit(int id, string can, string ssc, string csu) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "EditGet"; return(View("Error")); } ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Check Exists if (clientAccount == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(id, true); //Check Exists if (creditCard == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); //Check Exists if (clientSubUnit == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } creditCard.ClientAccountName = clientAccount.ClientAccountName; creditCard.ClientAccountNumber = clientAccount.ClientAccountNumber; creditCard.SourceSystemCode = clientAccount.SourceSystemCode; creditCard.ClientSubUnitName = clientSubUnit.ClientSubUnitName; CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository(); SelectList creditCardVendorsList = new SelectList(creditCardVendorRepository.GetAllCreditCardVendors().ToList(), "CreditCardVendorCode", "CreditCardVendorName", creditCard.CreditCardVendorCode); ViewData["CreditCardVendorsList"] = creditCardVendorsList; SelectList clientTopUnitsList = new SelectList(clientAccountRepository.GetClientAccountClientTopUnits(can, ssc).ToList(), "ClientTopUnitGuid", "ClientTopUnitName", creditCard.ClientTopUnitGuid); ViewData["ClientTopUnitList"] = clientTopUnitsList; CreditCardTypeRepository creditCardTypeRepository = new CreditCardTypeRepository(); SelectList creditCardTypeList = new SelectList(creditCardTypeRepository.GetAllCreditCardTypes().ToList(), "CreditCardTypeId", "CreditCardTypeDescription", creditCard.CreditCardTypeId);; ViewData["CreditCardTypeList"] = creditCardTypeList; //Populate List of Products ProductRepository productRepository = new ProductRepository(); SelectList products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName"); ViewData["ProductList"] = products; //Log View Of Credit Card LogRepository logRepository = new LogRepository(); logRepository.LogApplicationUsage(8, clientSubUnit.ClientSubUnitGuid, "", "", creditCard.CreditCardToken, creditCard.CreditCardTypeId, true); creditCardRepository.EditForDisplay(creditCard); return(View(creditCard)); }
public ActionResult Delete(TravelerTypeCreditCardVM travelerTypeCreditCardVM, FormCollection collection) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "DeletePost"; return(View("Error")); } //Check Exists int creditCardId = travelerTypeCreditCardVM.CreditCard.CreditCardId; CreditCardTravelerType creditCardTravelerType = new CreditCardTravelerType(); creditCardTravelerType = creditCardTravelerTypeRepository.GetCreditCardTravelerType(creditCardId); if (creditCardTravelerType == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } string csu = travelerTypeCreditCardVM.ClientSubUnit.ClientSubUnitGuid; string tt = travelerTypeCreditCardVM.TravelerType.TravelerTypeGuid; ClientSubUnitTravelerType clientSubUnitTravelerType = new ClientSubUnitTravelerType(); clientSubUnitTravelerType = clientSubUnitTravelerTypeRepository.GetClientSubUnitTravelerType(csu, tt); //Check Exists if (clientSubUnitTravelerType == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnitCreditCards(csu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(creditCardId, false); //Delete Item try { creditCard.ClientSubUnitGuid = csu; creditCard.TravelerTypeGuid = tt; creditCard.VersionNumber = Int32.Parse(collection["CreditCard.VersionNumber"]); creditCardTravelerTypeRepository.Delete(creditCard); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/CreditCardTravelerType.mvc/Delete?id=" + creditCardId.ToString() + "&csu=" + csu; 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 { csu = csu, tt = tt })); }
public ActionResult Edit(TravelerTypeCreditCardEditableVM travelerTypeCreditCardVM, FormCollection collection) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "EditPost"; return(View("Error")); } int creditCardId = travelerTypeCreditCardVM.CreditCard.CreditCardId; //Check Exists CreditCardTravelerType creditCardTravelerType = new CreditCardTravelerType(); creditCardTravelerType = creditCardTravelerTypeRepository.GetCreditCardTravelerType(creditCardId); if (creditCardTravelerType == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } string csu = travelerTypeCreditCardVM.ClientSubUnit.ClientSubUnitGuid; string tt = travelerTypeCreditCardVM.TravelerType.TravelerTypeGuid; //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnitCreditCards(csu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Get Item From Database CreditCardEditable creditCard = new CreditCardEditable(); creditCard = creditCardRepository.GetCreditCardEditable(creditCardId, false); //Update Model From Form + Validate against DB try { UpdateModel <CreditCardEditable>(creditCard, "CreditCard"); } 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")); } //Database Update try { creditCard.ClientSubUnitGuid = csu; creditCard.TravelerTypeGuid = tt; creditCard.VersionNumber = Int32.Parse(collection["CreditCard.VersionNumber"]); creditCardRepository.Edit(creditCard); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/CreditCardTravelerType.mvc/Edit?id=" + creditCardId.ToString() + "&csu=" + csu; 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 { csu = csu, tt = tt })); }
// GET: /Edit public ActionResult Edit(int id, string csu) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "EditGet"; return(View("Error")); } //Check Exists CreditCardTravelerType creditCardTravelerType = new CreditCardTravelerType(); creditCardTravelerType = creditCardTravelerTypeRepository.GetCreditCardTravelerType(id); if (creditCardTravelerType == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //string csu = creditCardTravelerType.ClientSubUnitGuid; string tt = creditCardTravelerType.TravelerTypeGuid; //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnitCreditCards(csu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } TravelerTypeCreditCardVM travelerTypeCreditCardVM = new TravelerTypeCreditCardVM(); travelerTypeCreditCardVM.TravelerType = travelerTypeRepository.GetTravelerType(tt); travelerTypeCreditCardVM.ClientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(id, true); creditCardRepository.EditForDisplay(creditCard); travelerTypeCreditCardVM.CreditCard = creditCard; CreditCardTypeRepository creditCardTypeRepository = new CreditCardTypeRepository(); travelerTypeCreditCardVM.CreditCardTypes = new SelectList(creditCardTypeRepository.GetAllCreditCardTypes().ToList(), "CreditCardTypeId", "CreditCardTypeDescription", creditCard.CreditCardTypeId); CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository(); travelerTypeCreditCardVM.CreditCardVendors = new SelectList(creditCardVendorRepository.GetAllCreditCardVendors().ToList(), "CreditCardVendorCode", "CreditCardVendorName", creditCard.CreditCardVendorCode); //Populate List of Products ProductRepository productRepository = new ProductRepository(); SelectList products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName"); ViewData["ProductList"] = products; //Log View Of Credit Card LogRepository logRepository = new LogRepository(); logRepository.LogApplicationUsage(8, csu, tt, "", creditCard.CreditCardToken, creditCard.CreditCardTypeId, true); //Show Form return(View(travelerTypeCreditCardVM)); }
public CWTCreditCardsVM(CreditCardBehavior creditCardBehavior, CWTPaginatedList <spDesktopDataAdmin_SelectCWTCreditCards_v1Result> creditCards) { CreditCardBehavior = creditCardBehavior; CreditCards = creditCards; }
// GET: /Edit public ActionResult Edit(int id) { //Check if changes are allowed to Cards for this Database CreditCardBehavior creditCardBehavior = new CreditCardBehavior(); creditCardBehavior = creditCardRepository.GetCreditCardBehavior(); if (!creditCardBehavior.CanChangeCreditCardsFlag) { ViewData["ActionMethod"] = "EditGet"; return(View("Error")); } CreditCard creditCard = new CreditCard(); creditCard = creditCardRepository.GetCreditCard(id, true); //Check Exists if (creditCard == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check Exists CreditCardClientSubUnit creditCardClientSubUnit = new CreditCardClientSubUnit(); creditCardClientSubUnit = creditCardClientSubUnitRepository.GetCreditCardClientSubUnit(id); if (creditCardClientSubUnit == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnitCreditCards(creditCardClientSubUnit.ClientSubUnitGuid)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository(); SelectList creditCardVendorsList = new SelectList(creditCardVendorRepository.GetAllCreditCardVendors().ToList(), "CreditCardVendorCode", "CreditCardVendorName", creditCard.CreditCardVendorCode); ViewData["CreditCardVendorsList"] = creditCardVendorsList; CreditCardTypeRepository creditCardTypeRepository = new CreditCardTypeRepository(); ViewData["CreditCardTypeList"] = new SelectList(creditCardTypeRepository.GetAllCreditCardTypes().ToList(), "CreditCardTypeId", "CreditCardTypeDescription", creditCard.CreditCardTypeId);; //Populate List of Products ProductRepository productRepository = new ProductRepository(); SelectList products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName", creditCard.ProductId); ViewData["ProductList"] = products; //Log View Of Credit Card LogRepository logRepository = new LogRepository(); logRepository.LogApplicationUsage(8, creditCardClientSubUnit.ClientSubUnitGuid, "", "", creditCard.CreditCardToken, creditCard.CreditCardTypeId, true); //Show Create Form creditCardRepository.EditForDisplay(creditCard); return(View(creditCard)); }