Beispiel #1
0
        // GET: Create A Single MerchantFee
        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"));
            }

            MerchantFeeVM merchantFeeVM = new MerchantFeeVM();

            MerchantFee merchantFee = new MerchantFee();

            merchantFeeVM.MerchantFee = merchantFee;

            CountryRepository countryRepository = new CountryRepository();

            merchantFeeVM.Countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName");

            CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository();

            merchantFeeVM.CreditCardVendors = new SelectList(creditCardVendorRepository.GetAllCreditCardVendors().ToList(), "CreditCardVendorCode", "CreditCardVendorName");

            ProductRepository productRepository = new ProductRepository();

            merchantFeeVM.Products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName");

            return(View(merchantFeeVM));
        }
Beispiel #2
0
        public ActionResult Delete(int id)
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Get Item From Database
            MerchantFee merchantFee = new MerchantFee();

            merchantFee = merchantFeeRepository.GetItem(id);

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

            MerchantFeeVM merchantFeeVM = new MerchantFeeVM();

            merchantFeeRepository.EditForDisplay(merchantFee);
            merchantFeeVM.MerchantFee = merchantFee;

            return(View(merchantFeeVM));
        }
Beispiel #3
0
        public ActionResult Edit(MerchantFeeVM merchantFeeVM)
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            MerchantFee merchantFee = new MerchantFee();

            merchantFee = merchantFeeRepository.GetItem(merchantFeeVM.MerchantFee.MerchantFeeId);

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

            //Update  Model from Form
            try
            {
                UpdateModel(merchantFee, "MerchantFee");
            }
            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
            {
                merchantFeeRepository.Update(merchantFee);
            }
            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"));
        }
Beispiel #4
0
        public ActionResult Create(MerchantFeeVM merchantFeeVM)
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Update Model From Form + Validate against DB
            try
            {
                UpdateModel <MerchantFee>(merchantFeeVM.MerchantFee, "MerchantFee");
            }
            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
            {
                merchantFeeRepository.Add(merchantFeeVM.MerchantFee);
            }
            catch (SqlException ex)
            {
                //Non-Unique Name
                if (ex.Message == "NonUniqueName")
                {
                    ViewData["Message"] = "There is already a Merchant Fee with this Country/CreditCard/Product/Supplier combination. Please go back and change one of these items";
                    return(View("Error"));
                }

                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"));
        }
Beispiel #5
0
        // GET: Edit A Single MerchantFee
        public ActionResult Edit(int id)
        {
            //Get Item From Database
            MerchantFee merchantFee = new MerchantFee();

            merchantFee = merchantFeeRepository.GetItem(id);

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

            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            MerchantFeeVM merchantFeeVM = new MerchantFeeVM();

            merchantFee.MerchantFeePercentMaximum = 100;

            merchantFeeRepository.EditForDisplay(merchantFee);
            merchantFeeVM.MerchantFee = merchantFee;

            CountryRepository countryRepository = new CountryRepository();

            merchantFeeVM.Countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName", merchantFee.CountryCode);

            CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository();

            merchantFeeVM.CreditCardVendors = new SelectList(creditCardVendorRepository.GetAllCreditCardVendors().ToList(), "CreditCardVendorCode", "CreditCardVendorName", merchantFee.CreditCardVendorCode);

            ProductRepository productRepository = new ProductRepository();

            merchantFeeVM.Products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName", merchantFee.ProductId);

            return(View(merchantFeeVM));
        }
Beispiel #6
0
        // GET: View A Single MerchantFee
        public ActionResult View(int id)
        {
            //Get Item From Database
            MerchantFee merchantFee = new MerchantFee();

            merchantFee = merchantFeeRepository.GetItem(id);

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

            MerchantFeeVM merchantFeeVM = new MerchantFeeVM();

            merchantFeeRepository.EditForDisplay(merchantFee);
            merchantFeeVM.MerchantFee = merchantFee;

            return(View(merchantFeeVM));
        }