public bool Check(Trade trade)
        {
            var product = trade.Product;
            var swap = product as Swap;
            var cdsindex = product as CDSIndex;
            Boolean result = true;

            //Only check this rule for the manual trades
            if (Utilities.IsNullOrEmpty(trade.TradingSystem))
            {
                if (swap != null)
                {
                    var currencyMAT = new String[] { "USD", "EUR", "GBP" };

                    if (currencyMAT.Contains(swap.Currency.ToString()) && ((swap.PayLeg.IsFixedRate && swap.ReceiveLeg.IsFloating) || (swap.PayLeg.IsFloating && swap.ReceiveLeg.IsFixedRate)))
                    {
                        Leg fixedLeg = swap.PayLeg.IsFixedRate ? swap.PayLeg : swap.ReceiveLeg;
                        Leg floatingLeg = swap.PayLeg.IsFloating ? swap.PayLeg : swap.ReceiveLeg;

                        CurrentSwap curSwap = new CurrentSwap();
                        curSwap.Currency = swap.Currency.ToString();
                        curSwap.StartDateRule = floatingLeg.RollConvention.ToString();
                        curSwap.TradeDate = new SimpleDate(trade.TradeTime);
                        curSwap.StartDate = swap.StartDate;
                        curSwap.FloatingRateIndex = floatingLeg.RateIndexDescription;
                        curSwap.FixedPaymentFrequ = fixedLeg.PaymentFrequency.ToString();
                        curSwap.FixedDayCountFraction = fixedLeg.Daycount.ToString();
                        curSwap.FloatingPaymentFrequ = floatingLeg.PaymentFrequency.ToString();
                        curSwap.FloatingFixingFrequ = floatingLeg.RateIndexTenor.ToString();
                        curSwap.FloatingDayCountFraction = floatingLeg.Daycount.ToString();
                        curSwap.FloatingAmortType = floatingLeg.AmortType.ToString();
                        var tenorPrefix = (swap.EndDate - swap.StartDate) / 365;
                        curSwap.Maturity = tenorPrefix.ToString() + 'Y';
                        curSwap.FloatingHolidayCalendar = floatingLeg.FixingMarketPlaces;
                        curSwap.FloatingBusinessDayConvention = floatingLeg.BusinessDayConvention.ToString();

                        if (swap.Currency.ToString().Equals("USD"))
                        {
                            if (CheckIfMAT(curSwap, new SwapUSD1()) || CheckIfMAT(curSwap, new SwapUSD2()))
                            {
                                result = false; //If MAT Trade we block the trade on the workflow
                            }
                        }
                        else if (swap.Currency.ToString().Equals("EUR"))
                        {
                            if (CheckIfMAT(curSwap, new SwapEUR()))
                            {
                                result = false; //If MAT Trade we block the trade on the workflow
                            }
                        }
                        else if (swap.Currency.ToString().Equals("GBP"))
                        {
                            result = false; //If MAT Trade we block the trade on the workflow
                        }
                    }
                }
                else if (cdsindex != null)
                {
                    var indexMAT = new String[] { "CDX.NA.IG", "CDX.NA.HY", "iTraxx Europe", "iTraxx Europe Crossover" };
                    var tenorMAT = new String[] { "5Y" };
                    var subFamily = cdsindex.Ticker.IndexSubFamily;
                    var series = cdsindex.Ticker.IndexSeries;
                    Tenor tenor = cdsindex.ProtectionMaturity;

                    if (indexMAT.Contains(subFamily) && tenorMAT.Contains(tenor.ToString()))
                    {
                        IList<CreditTicker> tickerList = Env.Current.Trade.GetAllCreditTickerLike(subFamily + "%");
                        var tickers = new List<CreditTicker>();
                        var maxVersion = 0;
                        foreach (var creditTicker in tickerList)
                        {
                            if (subFamily.Equals(creditTicker.IndexSubFamily) && creditTicker.IndexSeries >= series)
                            {
                                maxVersion = creditTicker.IndexSeries;
                            }
                        }

                        if (maxVersion == series || (maxVersion - 1 == series))
                        {
                            result = false;
                        }
                    }
                }
            }

            return result;
        }
        private bool CheckIfMAT(CurrentSwap curSwap, SwapMAT swapMAT)
        {
            var result = false;

            switch (1)
            {
                case 1: //Check the Floating Rate Index
                    result = swapMAT.FloatingRateIndex.Contains(curSwap.FloatingRateIndex);
                    if (result)
                        goto case 2;
                    else
                        break;
                case 2: //Check the Start Date rule
                    var rule = swapMAT.StartDateRule;
                    if (rule.Equals("T+0"))
                    {
                        result = curSwap.StartDate.Equals(curSwap.TradeDate);
                    }
                    else if (rule.Equals("T+2"))
                    {
                        ICalendar cal = CalendarHelper.Get(curSwap.FloatingHolidayCalendar);
                        SimpleDate nextBusinessDay = NextBusinessDay(cal, curSwap.TradeDate, 2);
                        result = nextBusinessDay.Equals(curSwap.StartDate);
                    }
                    else if (rule.Equals("IMM"))
                    {
                        result = rule.Equals(curSwap.StartDateRule);
                    }
                    if (result)
                        goto case 3;
                    else
                        break;
                case 3: //Check the Payment Frequency on the fixed leg
                    result = swapMAT.FixedPaymentFrequ.Contains(curSwap.FixedPaymentFrequ);
                    if (result)
                        goto case 4;
                    else
                        break;
                case 4: //Check the Day Count Fraction on the fixed leg
                    result = swapMAT.FixedDayCountFraction.Contains(curSwap.FixedDayCountFraction);
                    if (result)
                        goto case 5;
                    else
                        break;
                case 5: //Check the Payment Frequency on the floating leg
                    string paymentFrequency = null;
                    var getKey1 = swapMAT.FloatingPaymentFrequ.TryGetValue(curSwap.FloatingRateIndex, out paymentFrequency);
                    if (getKey1)
                    {
                        var keys = paymentFrequency.Split('+');
                        result = keys.Contains(curSwap.FloatingPaymentFrequ);
                    }
                    if (result)
                        goto case 6;
                    else
                        break;
                case 6: //Check the Fixing Frequency on the floating leg
                    string fixingFrequency = null;
                    var getKey2 = swapMAT.FloatingFixingFrequ.TryGetValue(curSwap.FloatingRateIndex, out fixingFrequency);
                    if (getKey2)
                    {
                        var keys = fixingFrequency.Split('+');
                        result = keys.Contains(curSwap.FloatingFixingFrequ);
                    }
                    if (result)
                        goto case 7;
                    else
                        break;
                case 7: //Check the Day Count Fraction on the floating leg
                    result = swapMAT.FloatingDayCountFraction.Contains(curSwap.FloatingDayCountFraction);
                    if (result)
                        goto case 8;
                    else
                        break;
                case 8: //Check if the notional is variable (amortization)
                    result = curSwap.FloatingAmortType.Equals(AmortType.None.ToString());
                    if (result)
                        goto case 9;
                    else
                        break;
                case 9: //Check the Maturity of the trade
                    result = swapMAT.Maturity.Contains(curSwap.Maturity);
                    if (result)
                        goto case 10;
                    else
                        break;
                case 10: //Check the Business Calendar of the floating leg
                    Char[] separator = new Char[] {':'};
                    var calendars = curSwap.FloatingHolidayCalendar.Split(separator);
                    foreach (string calendar in calendars) {
                        result = swapMAT.FloatingHolidayCalendar.Contains(calendar.Trim());
                        if (!result)
                            break;
                    }
                    if (result)
                        goto case 11;
                    else
                        break;
                case 11: //Check the Business Day Convention of the floating leg
                    result = swapMAT.FloatingBusinessDayConvention.Contains(curSwap.FloatingBusinessDayConvention);
                    if (result)
                        return true;
                    else
                        break;
            }

            return result;
        }