示例#1
0
        // GET: /View
        public ActionResult View(string csu, int id)
        {
            //Check Exists
            CreditCardTravelerType creditCardTravelerType = new CreditCardTravelerType();

            creditCardTravelerType = creditCardTravelerTypeRepository.GetCreditCardTravelerType(id);

            if (creditCardTravelerType == null)
            {
                ViewData["ActionMethod"] = "ViewGet";
                return(View("RecordDoesNotExistError"));
            }

            string tt = creditCardTravelerType.TravelerTypeGuid;
            ClientSubUnitTravelerType clientSubUnitTravelerType = new ClientSubUnitTravelerType();

            clientSubUnitTravelerType = clientSubUnitTravelerTypeRepository.GetClientSubUnitTravelerType(csu, tt);

            //Check Exists
            if (clientSubUnitTravelerType == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            TravelerTypeCreditCardVM travelerTypeCreditCardVM = new TravelerTypeCreditCardVM();

            travelerTypeCreditCardVM.TravelerType  = travelerTypeRepository.GetTravelerType(tt);
            travelerTypeCreditCardVM.ClientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu);


            CreditCard creditCard = new CreditCard();

            creditCard = creditCardRepository.GetCreditCard(id, false);
            creditCardRepository.EditForDisplay(creditCard);
            travelerTypeCreditCardVM.CreditCard = creditCard;

            //Log View Of Credit Card
            LogRepository logRepository = new LogRepository();

            logRepository.LogApplicationUsage(8, csu, tt, "", creditCard.CreditCardToken, creditCard.CreditCardTypeId, true);

            return(View(travelerTypeCreditCardVM));
        }
示例#2
0
        public ActionResult Delete(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"] = "DeleteGet";
                return(View("Error"));
            }

            //Check Exists
            CreditCardTravelerType creditCardTravelerType = new CreditCardTravelerType();

            creditCardTravelerType = creditCardTravelerTypeRepository.GetCreditCardTravelerType(id);

            if (creditCardTravelerType == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                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, false);
            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);

            //Log View Of Credit Card
            LogRepository logRepository = new LogRepository();

            logRepository.LogApplicationUsage(8, csu, tt, "", creditCard.CreditCardToken, creditCard.CreditCardTypeId, true);

            //Show Form
            return(View(travelerTypeCreditCardVM));
        }
示例#3
0
        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 }));
        }
示例#4
0
        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 }));
        }