// GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get Item From Database
            PriceTrackingHandlingFeeItem priceTrackingHandlingFeeItem = new PriceTrackingHandlingFeeItem();

            priceTrackingHandlingFeeItem = priceTrackingHandlingFeeItemRepository.PriceTrackingHandlingFeeItem(id);

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

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPriceTrackingHandlingFeeGroup(priceTrackingHandlingFeeItem.PriceTrackingHandlingFeeGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            PriceTrackingHandlingFeeItemVM priceTrackingHandlingFeeItemVM = new PriceTrackingHandlingFeeItemVM();

            priceTrackingHandlingFeeItemRepository.EditForDisplay(priceTrackingHandlingFeeItem);

            PriceTrackingHandlingFeeGroup priceTrackingHandlingFeeGroup = new PriceTrackingHandlingFeeGroup();

            priceTrackingHandlingFeeGroup = priceTrackingHandlingFeeGroupRepository.GetGroup(priceTrackingHandlingFeeItem.PriceTrackingHandlingFeeGroupId);
            if (priceTrackingHandlingFeeGroup != null)
            {
                priceTrackingHandlingFeeItem.PriceTrackingHandlingFeeGroupId = priceTrackingHandlingFeeGroup.PriceTrackingHandlingFeeGroupId;
                priceTrackingHandlingFeeItemVM.PriceTrackingHandlingFeeItem  = priceTrackingHandlingFeeItem;
                ViewData["PriceTrackingHandlingFeeGroupId"]   = priceTrackingHandlingFeeGroup.PriceTrackingHandlingFeeGroupId;
                ViewData["PriceTrackingHandlingFeeGroupName"] = priceTrackingHandlingFeeGroup.PriceTrackingHandlingFeeGroupName;
            }

            PriceTrackingSystemRepository priceTrackingSystemRepository = new PriceTrackingSystemRepository();
            SelectList priceTrackingSystems = new SelectList(priceTrackingSystemRepository.GetAllPriceTrackingSystems().ToList(), "PriceTrackingSystemId", "PriceTrackingSystemName", priceTrackingHandlingFeeItem.PriceTrackingSystemId);

            ViewData["PriceTrackingSystemList"] = priceTrackingSystems;

            ProductRepository productRepository = new ProductRepository();
            SelectList        products          = new SelectList(productRepository.GetPriceTrackerEligibleProducts().ToList(), "ProductId", "ProductName", priceTrackingHandlingFeeItem.ProductId);

            ViewData["ProductList"] = products;


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

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPriceTrackingHandlingFeeGroup(id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            PriceTrackingHandlingFeeItemVM priceTrackingHandlingFeeItemVM = new PriceTrackingHandlingFeeItemVM();

            PriceTrackingHandlingFeeGroup priceTrackingHandlingFeeGroup = new PriceTrackingHandlingFeeGroup();

            priceTrackingHandlingFeeGroup = priceTrackingHandlingFeeGroupRepository.GetGroup(id);
            if (priceTrackingHandlingFeeGroup != null)
            {
                PriceTrackingHandlingFeeItem priceTrackingHandlingFeeItem = new PriceTrackingHandlingFeeItem();
                priceTrackingHandlingFeeItem.PriceTrackingHandlingFeeGroupId = priceTrackingHandlingFeeGroup.PriceTrackingHandlingFeeGroupId;
                priceTrackingHandlingFeeItemVM.PriceTrackingHandlingFeeItem  = priceTrackingHandlingFeeItem;
                ViewData["PriceTrackingHandlingFeeGroupId"]   = priceTrackingHandlingFeeGroup.PriceTrackingHandlingFeeGroupId;
                ViewData["PriceTrackingHandlingFeeGroupName"] = priceTrackingHandlingFeeGroup.PriceTrackingHandlingFeeGroupName;
            }

            PriceTrackingSystemRepository priceTrackingSystemRepository = new PriceTrackingSystemRepository();
            SelectList priceTrackingSystems = new SelectList(priceTrackingSystemRepository.GetAllPriceTrackingSystems().ToList(), "PriceTrackingSystemId", "PriceTrackingSystemName");

            ViewData["PriceTrackingSystemList"] = priceTrackingSystems;

            ProductRepository productRepository = new ProductRepository();
            SelectList        products          = new SelectList(productRepository.GetPriceTrackerEligibleProducts().ToList(), "ProductId", "ProductName");

            ViewData["ProductList"] = products;

            return(View(priceTrackingHandlingFeeItemVM));
        }