Esempio n. 1
0
    public InsuranceMaterial SearchInsuranceByB2B(Terms.Sales.Business.InsuranceSearchCondition insuranceCondition)
    {
        TERMS.Common.Search.InsuranceSearchCondition Condition = new TERMS.Common.Search.InsuranceSearchCondition();

        Condition.InsuranceType = insuranceCondition.InsuranceType;

        Condition.Trip = new TERMS.Common.Trip();

        Condition.Trip.DepartureDate = insuranceCondition.DepartureDate;
        Condition.Trip.ReturnDate = insuranceCondition.ReturnDate;
        Condition.Trip.InitialTripDepositDate = DateTime.Now;

        List<TERMS.Common.Traveler> list = new List<TERMS.Common.Traveler>();

        for (int i = 0; i < insuranceCondition.TravelerCount; i++)
        {
            TERMS.Common.Traveler t = new TERMS.Common.Traveler();

            t.BirthDate = DateTime.Now.AddYears(-10);

            t.TripCost = Convert.ToDouble(insuranceCondition.TotalTripCost / insuranceCondition.TravelerCount);

            list.Add(t);
        }

        Condition.Travelers = list.ToArray();

        InsuranceProductSearcher INs = new InsuranceProductSearcher();

        try
        {
            IList<InsuranceProduct> products = INs.Search(Condition);

            if (products != null && products.Count > 0)
            {
                return ((TERMS.Business.Centers.ProductCenter.Components.InsuranceMaterial)((TERMS.Core.Product.ComponentGroup)products[0].Items[0]).Items[0]);
            }
            else
            {
                InsuranceMaterial insurance = new InsuranceMaterial(new TERMS.Core.Profiles.Profile("insurance"));

                insurance.PolicyQuote = new TERMS.Common.PolicyQuote();

                insurance.PolicyQuote.Status = new TERMS.Common.Status();

                insurance.PolicyQuote.Status.IsSuccess = false;

                insurance.PolicyQuote.Status.ErrorDescription = "None Insurance products";

                return insurance;
            }
        }
        catch (Exception ex)
        {
            InsuranceMaterial insurance = new InsuranceMaterial(new TERMS.Core.Profiles.Profile("insurance"));

            insurance.PolicyQuote = new TERMS.Common.PolicyQuote();

            insurance.PolicyQuote.Status = new TERMS.Common.Status();

            insurance.PolicyQuote.Status.IsSuccess = false;

            insurance.PolicyQuote.Status.ErrorDescription = ex.Message;

            return insurance;
        }
    }
Esempio n. 2
0
    public InsuranceMaterial SearchInsurance(Terms.Sales.Business.InsuranceSearchCondition insuranceCondition)
    {
        TERMS.Common.Search.InsuranceSearchCondition Condition = new TERMS.Common.Search.InsuranceSearchCondition();

        Condition.InsuranceType = insuranceCondition.InsuranceType;

        Condition.Trip = new TERMS.Common.Trip();

        Condition.Trip.DepartureDate = insuranceCondition.DepartureDate;
        Condition.Trip.ReturnDate = insuranceCondition.ReturnDate;
        Condition.Trip.InitialTripDepositDate = DateTime.Now;

        List<TERMS.Common.Traveler> list = new List<TERMS.Common.Traveler>();

        for (int i = 0; i < insuranceCondition.TravelerCount; i++)
        {
            TERMS.Common.Traveler t = new TERMS.Common.Traveler();

            t.BirthDate = DateTime.Now.AddYears(-10);

            t.TripCost = Convert.ToDouble(insuranceCondition.TotalTripCost / insuranceCondition.TravelerCount);

            list.Add(t);
        }

        Condition.Travelers = list.ToArray();

        InsuranceProductSearcher INs = new InsuranceProductSearcher();
        IList<InsuranceProduct> products = null;
        try
        {
            products = INs.Search(Condition);
        }
        catch
        {
            return null;
        }

        if (products != null && products.Count > 0)
        {
            return ((TERMS.Business.Centers.ProductCenter.Components.InsuranceMaterial)((TERMS.Core.Product.ComponentGroup)products[0].Items[0]).Items[0]);
        }
        else
        {
            return null;
        }
    }