//Get one Item
        // public IQueryable<MerchantFee> GetAllItems()
        //{
        //    return db.MerchantFees.OrderBy(c => c.MerchantFeeDescription);
        //}

        public void EditForDisplay(MerchantFee merchantFee)
        {
            CountryRepository countryRepository = new CountryRepository();
            Country           country           = new Country();

            if (merchantFee.ProductId != null)
            {
                country = countryRepository.GetCountry(merchantFee.CountryCode);
                if (country != null)
                {
                    merchantFee.CountryName = country.CountryName;
                }
            }

            CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository();
            CreditCardVendor           creditCardVendor           = new CreditCardVendor();

            if (merchantFee.ProductId != null)
            {
                creditCardVendor = creditCardVendorRepository.GetCreditCardVendor(merchantFee.CreditCardVendorCode);
                if (creditCardVendor != null)
                {
                    merchantFee.CreditCardVendorName = creditCardVendor.CreditCardVendorName;
                }
            }

            SupplierRepository supplierRepository = new SupplierRepository();
            Supplier           supplier           = new Supplier();

            if (merchantFee.ProductId != null)
            {
                supplier = supplierRepository.GetSupplier(merchantFee.SupplierCode, (int)merchantFee.ProductId);
                if (supplier != null)
                {
                    merchantFee.SupplierName = supplier.SupplierName;
                }
            }

            ProductRepository productRepository = new ProductRepository();
            Product           product           = new Product();

            if (merchantFee.ProductId != null)
            {
                product = productRepository.GetProduct((int)merchantFee.ProductId);
                if (product != null)
                {
                    merchantFee.ProductName = product.ProductName;
                }
            }
        }
Example #2
0
        //Add Data From Linked Tables for Display
        //type is optional to letus know if it is a TopUnit card, which has no links to other tables
        public void EditForDisplay(CreditCardEditable creditCard)
        {
            ClientTopUnitRepository clientTopUnitRepository = new ClientTopUnitRepository();
            ClientTopUnit           clientTopUnit           = new ClientTopUnit();

            clientTopUnit = clientTopUnitRepository.GetClientTopUnit(creditCard.ClientTopUnitGuid);
            if (clientTopUnit != null)
            {
                creditCard.ClientTopUnitName = clientTopUnit.ClientTopUnitName;
            }

            CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository();
            CreditCardVendor           creditCardVendor           = new CreditCardVendor();

            creditCardVendor = creditCardVendorRepository.GetCreditCardVendor(creditCard.CreditCardVendorCode);
            if (creditCardVendor != null)
            {
                creditCard.CreditCardVendorName = creditCardVendor.CreditCardVendorName;
            }

            if (creditCard.CreditCardTypeId != null)
            {
                int creditCardTypeId = (int)creditCard.CreditCardTypeId;
                CreditCardTypeRepository creditCardTypeRepository = new CreditCardTypeRepository();
                CreditCardType           creditCardType           = new CreditCardType();
                creditCardType = creditCardTypeRepository.GetCreditCardType(creditCardTypeId);
                if (creditCardType != null)
                {
                    creditCard.CreditCardTypeDescription = creditCardType.CreditCardTypeDescription;
                }
            }

            //If Linked to ClientSubUnit
            CreditCardClientSubUnit           creditCardClientSubUnit           = new CreditCardClientSubUnit();
            CreditCardClientSubUnitRepository creditCardClientSubUnitRepository = new CreditCardClientSubUnitRepository();

            creditCardClientSubUnit = creditCardClientSubUnitRepository.GetCreditCardClientSubUnit(creditCard.CreditCardId);

            if (creditCardClientSubUnit != null)
            {
                ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                ClientSubUnit           clientSubUnit           = new ClientSubUnit();
                clientSubUnit = clientSubUnitRepository.GetClientSubUnit(creditCardClientSubUnit.ClientSubUnitGuid);
                if (clientSubUnit != null)
                {
                    creditCard.ClientSubUnitGuid = clientSubUnit.ClientSubUnitGuid;
                    creditCard.ClientSubUnitName = clientSubUnit.ClientSubUnitName;
                    creditCard.ClientTopUnitGuid = clientSubUnit.ClientTopUnit.ClientTopUnitGuid;
                    creditCard.ClientTopUnitName = clientSubUnit.ClientTopUnit.ClientTopUnitName;
                }
            }

            //If Linked to ClientAccount
            CreditCardClientAccount           creditCardClientAccount           = new CreditCardClientAccount();
            CreditCardClientAccountRepository creditCardClientAccountRepository = new CreditCardClientAccountRepository();

            creditCardClientAccount = creditCardClientAccountRepository.GetCreditCardClientAccount(creditCard.CreditCardId);

            if (creditCardClientAccount != null)
            {
                ClientAccountRepository clientAccountRepository = new ClientAccountRepository();
                ClientAccount           clientAccount           = new ClientAccount();
                clientAccount = clientAccountRepository.GetClientAccount(creditCardClientAccount.ClientAccountNumber, creditCardClientAccount.SourceSystemCode);
                if (clientAccount != null)
                {
                    creditCard.ClientAccountNumber = clientAccount.ClientAccountNumber;
                    creditCard.ClientAccountName   = clientAccount.ClientAccountName;
                    creditCard.SourceSystemCode    = clientAccount.SourceSystemCode;
                }
            }


            HierarchyRepository hierarchyRepository = new HierarchyRepository();

            fnDesktopDataAdmin_SelectCreditCardHierarchy_v1Result hierarchy = new fnDesktopDataAdmin_SelectCreditCardHierarchy_v1Result();

            hierarchy = GetGroupHierarchy(creditCard.CreditCardId);

            if (hierarchy == null)
            {
            }
            else
            {
                creditCard.HierarchyType = hierarchy.HierarchyType;
                creditCard.HierarchyCode = hierarchy.HierarchyCode.ToString();
                creditCard.HierarchyItem = hierarchy.HierarchyName.Trim();

                if (hierarchy.HierarchyType == "ClientSubUnitTravelerType")
                {
                    creditCard.ClientSubUnitGuid = hierarchy.HierarchyCode.ToString();
                    creditCard.ClientSubUnitName = hierarchy.HierarchyName.Trim();
                    creditCard.TravelerTypeGuid  = hierarchy.TravelerTypeGuid;
                    creditCard.TravelerTypeName  = hierarchy.TravelerTypeName.Trim();
                }
            }
        }