コード例 #1
0
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicyHotelCapRateGroupItem policyHotelCapRateGroupItem)
        {
            //PolicyGroupName
            PolicyGroupRepository policyGroupRepository = new PolicyGroupRepository();
            PolicyGroup           policyGroup           = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyHotelCapRateGroupItem.PolicyGroupId);
            policyHotelCapRateGroupItem.PolicyGroupName = policyGroup.PolicyGroupName;

            //Currency
            if (policyHotelCapRateGroupItem.CurrencyCode != null)
            {
                string             currencyCode       = policyHotelCapRateGroupItem.CurrencyCode;
                CurrencyRepository currencyRepository = new CurrencyRepository();
                Currency           currency           = new Currency();
                currency = currencyRepository.GetCurrency(currencyCode);
                policyHotelCapRateGroupItem.CurrencyName = currency.Name;
            }

            //PolicyLocation
            PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
            PolicyLocation           policyLocation           = new PolicyLocation();

            policyLocation = policyLocationRepository.GetPolicyLocation(policyHotelCapRateGroupItem.PolicyLocationId);
            if (policyLocation != null)
            {
                policyHotelCapRateGroupItem.PolicyLocation = policyLocation.PolicyLocationName;
            }
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicyHotelVendorGroupItem policyHotelVendorGroupItem)
        {
            //PolicyHotelStatusDescription
            if (policyHotelVendorGroupItem.PolicyHotelStatusId != null)
            {
                int policyHotelStatusId = (int)policyHotelVendorGroupItem.PolicyHotelStatusId;
                PolicyHotelStatusRepository policyHotelStatusRepository = new PolicyHotelStatusRepository();
                PolicyHotelStatus           policyHotelStatus           = new PolicyHotelStatus();
                policyHotelStatus = policyHotelStatusRepository.GetPolicyHotelStatus(policyHotelStatusId);
                policyHotelVendorGroupItem.PolicyHotelStatus = policyHotelStatus.PolicyHotelStatusDescription;
            }

            //PolicyGroupName
            PolicyGroupRepository policyGroupRepository = new PolicyGroupRepository();
            PolicyGroup           policyGroup           = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyHotelVendorGroupItem.PolicyGroupId);
            policyHotelVendorGroupItem.PolicyGroupName = policyGroup.PolicyGroupName;
            policyHotelVendorGroupItem.PolicyGroupId   = policyGroup.PolicyGroupId;

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

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

            //PolicyLocationName
            PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
            PolicyLocation           policyLocation           = new PolicyLocation();

            policyLocation = policyLocationRepository.GetPolicyLocation(policyHotelVendorGroupItem.PolicyLocationId);
            if (policyLocation != null)
            {
                policyHotelVendorGroupItem.PolicyLocationName = policyLocation.PolicyLocationName;
            }

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

            product = productRepository.GetProduct(policyHotelVendorGroupItem.ProductId);
            if (product != null)
            {
                policyHotelVendorGroupItem.ProductName = product.ProductName;
            }
        }
コード例 #3
0
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicyCarTypeGroupItem policyCarTypeGroupItem)
        {
            //PolicyGroupName
            PolicyGroupRepository policyGroupRepository = new PolicyGroupRepository();
            PolicyGroup           policyGroup           = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyCarTypeGroupItem.PolicyGroupId);
            policyCarTypeGroupItem.PolicyGroupName = policyGroup.PolicyGroupName;

            //CarStatus
            PolicyCarStatusRepository policyCarStatusRepository = new PolicyCarStatusRepository();
            PolicyCarStatus           policyCarStatus           = new PolicyCarStatus();

            policyCarStatus = policyCarStatusRepository.GetPolicyCarStatus(policyCarTypeGroupItem.PolicyCarStatusId);
            policyCarTypeGroupItem.PolicyCarStatusDescription = policyCarStatus.PolicyCarStatusDescription;

            //CarType Category
            CarTypeCategoryRepository carTypeCategoryRepository = new CarTypeCategoryRepository();
            CarTypeCategory           carTypeCategory           = new CarTypeCategory();

            carTypeCategory = carTypeCategoryRepository.GetCarTypeCategory(policyCarTypeGroupItem.CarTypeCategoryId);
            if (carTypeCategory != null)
            {
                policyCarTypeGroupItem.CarTypeCategoryName = carTypeCategory.CarTypeCategoryName;
            }

            //PolicyLocation
            PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
            PolicyLocation           policyLocation           = new PolicyLocation();

            policyLocation = policyLocationRepository.GetPolicyLocation(policyCarTypeGroupItem.PolicyLocationId);
            if (policyLocation != null)
            {
                policyCarTypeGroupItem.PolicyLocation = policyLocation.PolicyLocationName;
            }
        }
コード例 #4
0
        //Export Items to CSV
        public byte[] Export(int id)
        {
            StringBuilder sb = new StringBuilder();

            //Add Headers
            List <string> headers = new List <string>();

            headers.Add("Policy Group Name");
            headers.Add("Location Name");
            headers.Add("Location Code");
            headers.Add("Currency Name");
            headers.Add("Currency Code");
            headers.Add("Hotel Cap Rate Amount");
            headers.Add("Enabled Flag");
            headers.Add("Enabled Date");
            headers.Add("Expiry Date");
            headers.Add("Travel Date Valid From");
            headers.Add("Travel Date Valid To");
            headers.Add("Tax Inclusive Flag");
            headers.Add("Creation TimeStamp");
            headers.Add("Last Update Time Stamp");
            headers.Add("Advice");

            sb.AppendLine(String.Join(",", headers.Select(x => x.ToString()).ToArray()));

            //Add Items
            List <PolicyHotelCapRateGroupItem> policyHotelCapRateGroupItems = db.PolicyHotelCapRateGroupItems.Where(x => x.PolicyGroupId == id).ToList();

            foreach (PolicyHotelCapRateGroupItem item in policyHotelCapRateGroupItems)
            {
                //Edit Item
                EditItemForDisplay(item);

                //Location
                PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
                PolicyLocation           policyLocation           = new PolicyLocation();
                policyLocation = policyLocationRepository.GetPolicyLocation(item.PolicyLocationId);
                if (policyLocation != null)
                {
                    policyLocationRepository.EditForDisplay(policyLocation);
                }

                //Advice Count
                int adviceCount = 0;
                PolicyHotelCapRateGroupItemLanguageRepository policyHotelCapRateGroupItemLanguageRepository = new PolicyHotelCapRateGroupItemLanguageRepository();
                List <PolicyHotelCapRateGroupItemLanguage>    policyHotelCapRateGroupItemLanguages          = policyHotelCapRateGroupItemLanguageRepository.GetItems(item.PolicyHotelCapRateItemId);
                if (policyHotelCapRateGroupItemLanguages != null)
                {
                    adviceCount = policyHotelCapRateGroupItemLanguages.Count();
                }

                string date_format = "MM/dd/yy HH:mm";

                string short_date_format = "yyyy/MM/dd";

                sb.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}",
                                !string.IsNullOrEmpty(item.PolicyGroupName) ? item.PolicyGroupName : "",
                                !string.IsNullOrEmpty(policyLocation.LocationName) ? policyLocation.LocationName : "",
                                !string.IsNullOrEmpty(policyLocation.LocationCode) ? policyLocation.LocationCode : "",
                                !string.IsNullOrEmpty(item.CurrencyName) ? item.CurrencyName : "",
                                !string.IsNullOrEmpty(item.CurrencyCode) ? item.CurrencyCode : "",
                                item.CapRate.HasValue ? item.CapRate.Value.ToString() : "",
                                item.EnabledFlag == true ? "True" : "False",
                                item.EnabledDate.HasValue ? item.EnabledDate.Value.ToString(short_date_format) : "",
                                item.ExpiryDate.HasValue ? item.ExpiryDate.Value.ToString(short_date_format) : "",
                                item.TravelDateValidFrom.HasValue ? item.TravelDateValidFrom.Value.ToString(short_date_format) : "",
                                item.TravelDateValidTo.HasValue ? item.TravelDateValidTo.Value.ToString(short_date_format) : "",
                                item.TaxInclusiveFlag == true ? "True" : "False",
                                item.CreationTimestamp.HasValue ? item.CreationTimestamp.Value.ToString(date_format) : "",
                                item.LastUpdateTimestamp.HasValue ? item.LastUpdateTimestamp.Value.ToString(date_format) : "",
                                adviceCount > 0 ? "True" : "False"
                                );

                sb.Append(Environment.NewLine);
            }

            return(Encoding.ASCII.GetBytes(sb.ToString()));
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicySupplierDealCode policySupplierDealCode)
        {
            //PolicySupplierDealCodeType
            PolicySupplierDealCodeTypeRepository policySupplierDealCodeTypeRepository = new PolicySupplierDealCodeTypeRepository();
            PolicySupplierDealCodeType           policySupplierDealCodeType           = new PolicySupplierDealCodeType();

            policySupplierDealCodeType = policySupplierDealCodeTypeRepository.GetPolicySupplierDealCodeType(policySupplierDealCode.PolicySupplierDealCodeTypeId);
            if (policySupplierDealCodeType != null)
            {
                policySupplierDealCode.PolicySupplierDealCodeTypeDescription = policySupplierDealCodeType.PolicySupplierDealCodeTypeDescription;
            }

            //GDS
            GDSRepository gdsRepository = new GDSRepository();
            GDS           gds           = new GDS();

            gds = gdsRepository.GetGDS(policySupplierDealCode.GDSCode);
            if (gds != null)
            {
                policySupplierDealCode.GDSName = gds.GDSName;
            }

            //PolicyLocation
            PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
            PolicyLocation           policyLocation           = new PolicyLocation();

            policyLocation = policyLocationRepository.GetPolicyLocation((int)policySupplierDealCode.PolicyLocationId);
            if (policyLocation != null)
            {
                policySupplierDealCode.PolicyLocationName = policyLocation.PolicyLocationName;
            }

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

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

            //EnabledFlag is nullable
            if (policySupplierDealCode.EnabledFlag != true)
            {
                policySupplierDealCode.EnabledFlag = false;
            }
            policySupplierDealCode.EnabledFlagNonNullable = (bool)policySupplierDealCode.EnabledFlag;

            //OSIFlag is nullable
            if (policySupplierDealCode.OSIFlag != true)
            {
                policySupplierDealCode.OSIFlag = false;
            }
            policySupplierDealCode.OSIFlagNonNullable = (bool)policySupplierDealCode.OSIFlag;

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

            product = productRepository.GetProduct(policySupplierDealCode.ProductId);
            if (product != null)
            {
                policySupplierDealCode.ProductName = product.ProductName;
            }

            //PolicyGroup
            PolicyGroupRepository policyGroupRepository = new PolicyGroupRepository();
            PolicyGroup           policyGroup           = policyGroupRepository.GetGroup(policySupplierDealCode.PolicyGroupId);

            policySupplierDealCode.PolicyGroupName = policyGroup.PolicyGroupName;

            //Tour Code Type
            TourCodeTypeRepository tourCodeTypeRepository = new TourCodeTypeRepository();
            TourCodeType           tourCodeType           = tourCodeTypeRepository.GetTourCodeType(policySupplierDealCode.TourCodeTypeId ?? 0);

            if (tourCodeType != null)
            {
                policySupplierDealCode.TourCodeType = tourCodeType;
            }
        }
        //Export Items to CSV
        public byte[] Export(int id)
        {
            StringBuilder sb = new StringBuilder();

            //Add Headers
            List <string> headers = new List <string>();

            headers.Add("Policy Group Name");
            headers.Add("Deal Code Value");
            headers.Add("Deal Code Description");
            headers.Add("Deal Code Type Description");
            headers.Add("Location Name");
            headers.Add("Location Code");
            headers.Add("GDS Name ");
            headers.Add("Product Name");
            headers.Add("Supplier Name");
            headers.Add("Supplier Code");
            headers.Add("Travel Indicator Description");
            headers.Add("Travel Indicator");
            headers.Add("Endorsement");
            headers.Add("Endorsement Override");
            headers.Add("OSI 1");
            headers.Add("Enabled Flag");
            headers.Add("Enabled Date");
            headers.Add("Expiry Date");
            headers.Add("Creation TimeStamp");
            headers.Add("Last Update Time Stamp");

            sb.AppendLine(String.Join(",", headers.Select(x => x.ToString()).ToArray()));

            //Add Items
            List <PolicySupplierDealCode> policySupplierDealCodes = db.PolicySupplierDealCodes.Where(x => x.PolicyGroupId == id).ToList();

            foreach (PolicySupplierDealCode item in policySupplierDealCodes)
            {
                //Edit Item
                EditItemForDisplay(item);

                //Location
                PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
                PolicyLocation           policyLocation           = new PolicyLocation();
                policyLocation = policyLocationRepository.GetPolicyLocation(Int32.Parse(item.PolicyLocationId.ToString()));
                if (policyLocation != null)
                {
                    policyLocationRepository.EditForDisplay(policyLocation);
                }

                //TravelIndicator
                TravelIndicatorRepository travelIndicatorRepository = new TravelIndicatorRepository();
                TravelIndicator           travelIndicator           = new TravelIndicator();
                if (item.TravelIndicator != null)
                {
                    travelIndicator = travelIndicatorRepository.GetTravelIndicator(item.TravelIndicator);
                }

                //PolicySupplierDealCodeOSI
                PolicySupplierDealCodeOSI policySupplierDealCodeOSI = null;
                if (item.PolicySupplierDealCodeOSIs != null)
                {
                    policySupplierDealCodeOSI = item.PolicySupplierDealCodeOSIs.FirstOrDefault();
                }

                string date_format = "MM/dd/yy HH:mm";

                sb.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19}",
                                !string.IsNullOrEmpty(item.PolicyGroupName) ? item.PolicyGroupName : "",
                                !string.IsNullOrEmpty(item.PolicySupplierDealCodeValue) ? item.PolicySupplierDealCodeValue : "",
                                !string.IsNullOrEmpty(item.PolicySupplierDealCodeDescription) ? item.PolicySupplierDealCodeDescription : "",
                                !string.IsNullOrEmpty(item.PolicySupplierDealCodeTypeDescription) ? item.PolicySupplierDealCodeTypeDescription : "",

                                !string.IsNullOrEmpty(policyLocation.LocationName) ? policyLocation.LocationName : "",
                                !string.IsNullOrEmpty(policyLocation.LocationCode) ? policyLocation.LocationCode : "",

                                !string.IsNullOrEmpty(item.GDSName) ? item.GDSName : "",

                                !string.IsNullOrEmpty(item.ProductName) ? item.ProductName : "",
                                !string.IsNullOrEmpty(item.SupplierName) ? item.SupplierName : "",
                                !string.IsNullOrEmpty(item.SupplierCode) ? item.SupplierCode : "",

                                //Valid when Deal Code Type = Tour Code
                                travelIndicator != null && !string.IsNullOrEmpty(travelIndicator.TravelIndicatorDescription) ? travelIndicator.TravelIndicatorDescription : "",
                                item.TravelIndicator != null && !string.IsNullOrEmpty(item.TravelIndicator) ? item.TravelIndicator : "",
                                item.Endorsement != null && !string.IsNullOrEmpty(item.Endorsement) ? item.Endorsement : "",
                                item.EndorsementOverride != null && !string.IsNullOrEmpty(item.EndorsementOverride) ? item.EndorsementOverride : "",

                                policySupplierDealCodeOSI != null ? policySupplierDealCodeOSI.PolicySupplierDealCodeOSIDescription : "",
                                item.EnabledFlag == true ? "True" : "False",
                                item.EnabledDate.HasValue ? item.EnabledDate.Value.ToString(date_format) : "",
                                item.ExpiryDate.HasValue ? item.ExpiryDate.Value.ToString(date_format) : "",
                                item.CreationTimestamp.HasValue ? item.CreationTimestamp.Value.ToString(date_format) : "",
                                item.LastUpdateTimestamp.HasValue ? item.LastUpdateTimestamp.Value.ToString(date_format) : ""
                                );

                sb.Append(Environment.NewLine);
            }

            return(Encoding.ASCII.GetBytes(sb.ToString()));
        }
コード例 #7
0
        public void EditForDisplay(TransactionFeeCarHotel transactionFee)
        {
            TravelIndicatorRepository travelIndicatorRepository = new TravelIndicatorRepository();
            TravelIndicator           travelIndicator           = new TravelIndicator();

            travelIndicator = travelIndicatorRepository.GetTravelIndicator(transactionFee.TravelIndicator);
            if (travelIndicator != null)
            {
                transactionFee.TravelIndicatorDescription = travelIndicator.TravelIndicatorDescription;
            }

            CurrencyRepository currencyRepository = new CurrencyRepository();
            Currency           currency           = new Currency();

            currency = currencyRepository.GetCurrency(transactionFee.FeeCurrencyCode);
            if (currency != null)
            {
                transactionFee.FeeCurrencyName = currency.Name;
            }
            currency = currencyRepository.GetCurrency(transactionFee.TicketPriceCurrencyCode);
            if (currency != null)
            {
                transactionFee.TicketPriceCurrencyName = currency.Name;
            }


            BookingSourceRepository bookingSourceRepository = new BookingSourceRepository();
            BookingSource           bookingSource           = new BookingSource();

            bookingSource = bookingSourceRepository.GetBookingSource(transactionFee.BookingSourceCode);
            if (bookingSource != null)
            {
                transactionFee.BookingSourceDescription = bookingSource.BookingSourceDescription;
            }

            BookingOriginationRepository bookingOriginationRepository = new BookingOriginationRepository();
            BookingOrigination           bookingOrigination           = new BookingOrigination();

            bookingOrigination = bookingOriginationRepository.GetBookingOrigination(transactionFee.BookingOriginationCode);
            if (bookingOrigination != null)
            {
                transactionFee.BookingOriginationCode = bookingOrigination.BookingOriginationCode;
            }

            ChargeTypeRepository chargeTypeRepository = new ChargeTypeRepository();
            ChargeType           chargeType           = new ChargeType();

            chargeType = chargeTypeRepository.GetChargeType(transactionFee.ChargeTypeCode);
            if (bookingOrigination != null)
            {
                transactionFee.ChargeTypeDescription = chargeType.ChargeTypeDescription;
            }

            TravelerBackOfficeTypeRepository travelerBackOfficeTypeRepository = new TravelerBackOfficeTypeRepository();
            TravelerBackOfficeType           travelerBackOfficeType           = new TravelerBackOfficeType();

            travelerBackOfficeType = travelerBackOfficeTypeRepository.GetTravelerBackOfficeType(transactionFee.TravelerClassCode);
            if (travelerBackOfficeType != null)
            {
                transactionFee.TravelerBackOfficeTypeDescription = travelerBackOfficeType.TravelerBackOfficeTypeDescription;
            }

            if (transactionFee.ProductId != null)
            {
                ProductRepository productRepository = new ProductRepository();
                Product           product           = new Product();
                product = productRepository.GetProduct((int)transactionFee.ProductId);
                if (product != null)
                {
                    transactionFee.ProductName = product.ProductName;

                    //Supplier
                    if (!String.IsNullOrEmpty(transactionFee.SupplierCode))
                    {
                        SupplierRepository supplierRepository = new SupplierRepository();
                        Supplier           supplier           = new Supplier();
                        supplier = supplierRepository.GetSupplier(transactionFee.SupplierCode, (int)transactionFee.ProductId);
                        if (supplier != null)
                        {
                            transactionFee.SupplierName = supplier.SupplierName;
                        }
                    }
                }
            }

            if (transactionFee.PolicyLocationId != null)
            {
                PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
                PolicyLocation           policyLocation           = new PolicyLocation();
                policyLocation = policyLocationRepository.GetPolicyLocation((int)transactionFee.PolicyLocationId);
                if (policyLocation != null)
                {
                    transactionFee.PolicyLocationName = policyLocation.PolicyLocationName;
                }
            }

            //IncursGSTFlag is nullable
            if (transactionFee.IncursGSTFlag != true)
            {
                transactionFee.IncursGSTFlag = false;
            }
            transactionFee.IncursGSTFlagNonNullable = (bool)transactionFee.IncursGSTFlag;
        }