Ejemplo n.º 1
0
        //RAISE + BROADCAST
        private void RaiseAndBroadcast(SourceSug suggestion, Result results)
        {
            var runRule = false;

            //Event within 7 days
            if (suggestion.EventDateWithin(SevenDays)
                //Must have had RAISE+BROADCAST for past 5 days with price +/‐ $10
                && HasForPast(FiveDays, suggestion, LowestChange))
            {
                runRule = true;
            }
            //Event 7‐30 days
            else if (suggestion.EventDateFromTo(SevenDays, ThirtyDays)
                     //Must have had RAISE+BROADCAST for past 4 days with price +/‐ $10
                     && HasForPast(FourDays, suggestion, LowestChange))
            {
                runRule = true;
            }
            //Event > 30 days
            else if (
                //Must have had RAISE+BROADCAST for past 3 days with price +/‐ $10
                HasForPast(ThreeDays, suggestion, LowestChange))
            {
                runRule = true;
            }

            SaveResultToDatabase(suggestion, results, runRule);
        }
Ejemplo n.º 2
0
        //RAISE
        private void Raise(SourceSug suggestion, Result results)
        {
            if (!suggestion.Event_Date.HasValue)
            {
                throw new ArgumentNullException(nameof(suggestion.Event_Date));
            }

            var runRule = false;

            //Event within 7 days
            if (suggestion.EventDateWithin(SevenDays))
            {
                if (
                    //Change < $10 and sug has RAISE for past 2 days
                    (suggestion.ChangeLower(LowestChange) && HasForPast(TwoDays, suggestion))
                    //Change $10 ‐ $30 and sug has RAISE $10‐$30 for past 1 days
                    || (suggestion.ChangeHigher(LowestChange) && suggestion.ChangeLowerOrEquals(HighestChange) &&
                        HasForPast(OneDay, suggestion, LowestChange, HighestChange))
                    //Change > $30
                    || suggestion.ChangeHigher(HighestChange))
                {
                    runRule = true;
                }
            }
            //Event 7-30 days
            else if (suggestion.EventDateFromTo(SevenDays, ThirtyDays))
            {
                if (
                    //Change < $10 and sug has RAISE for past 4 days
                    (suggestion.ChangeLower(LowestChange) && HasForPast(FourDays, suggestion))
                    //Change $10 ‐ $30 and sug has RAISE $10‐$30 for past 3 days
                    || (suggestion.ChangeHigherOrEquals(LowestChange) && suggestion.ChangeLowerOrEquals(HighestChange) &&
                        HasForPast(ThreeDays, suggestion, LowestChange, HighestChange))
                    //Change > $30 and sug has RAISE +/‐ $10 for past 2 days
                    || (suggestion.ChangeHigher(HighestChange) && HasForPast(TwoDays, suggestion, LowestChange)))
                {
                    runRule = true;
                }
            }
            //Event > 30 days
            else
            {
                if (
                    //Change < $10 and sug has RAISE for past 6 days
                    (suggestion.ChangeLower(LowestChange) && HasForPast(SixDays, suggestion))
                    //Change $10 ‐ $30 and sug has RAISE $10‐$30 for past 5 days
                    || (suggestion.ChangeHigher(LowestChange) && suggestion.ChangeLowerOrEquals(HighestChange) &&
                        HasForPast(FiveDays, suggestion, LowestChange, HighestChange))
                    //Change > $30 and sug has RAISE +/‐ $10 for past 4 days
                    || (suggestion.ChangeHigher(HighestChange) && HasForPast(FourDays, suggestion, LowestChange)))
                {
                    runRule = true;
                }
            }
            SaveResultToDatabase(suggestion, results, runRule);
        }
Ejemplo n.º 3
0
        //UNBROADCAST
        private void Unbroadcast(SourceSug sug, Result results, bool forceUnbroadcast = false)
        {
            if (forceUnbroadcast)
            {
                sug.Action = SuggestionRulesStrings.Unbroadcast;

                SaveResultToDatabase(sug, results, runRule: true);

                OnEventHappened("Suggested price is higher than " + MaxPrice + "$ (actually " + sug.SugPrice + ").");
                OnEventHappened("Force " + SuggestionRulesStrings.Unbroadcast + " applied.");

                return;
            }

            var runRule = true;

            //Event < 12 days
            if (sug.EventDateWithin(TwelveDays))
            {
                int day = GetDayForUnbroudcast(sug);

                switch (day)
                {
                //First day -> add 20% to price
                case 1:
                    sug.IncreasePrice(percentage: Twenty);
                    break;

                //Second day -> add 20% to price
                case 2:
                    sug.IncreasePrice(percentage: Twenty);
                    break;

                //Third day -> add 30% to price
                case 3:
                    sug.IncreasePrice(percentage: Thirty);
                    break;

                //Fourth day -> Unbroadcast
                case 4:
                    break;

                default:
                    runRule = false;
                    break;
                }
            }
            //Event 12‐30 days
            else if (sug.EventDateFromTo(TwelveDays, ThirtyDays))
            {
                int day = GetDayForUnbroudcast(sug);

                // 12 == it is first day, 13 == second day, etc
                switch (day)
                {
                //Second day -> add 10% to price
                case 1 + TwelveDays:
                    sug.IncreasePrice(percentage: Ten);
                    break;

                //Third day -> add 15% to price
                case 2 + TwelveDays:
                    sug.IncreasePrice(percentage: Fifteen);
                    break;

                //Fourth day -> add 20% to price
                case 3 + TwelveDays:
                    sug.IncreasePrice(percentage: Twenty);
                    break;

                //Fifth day -> Unbroadcast
                case 4 + TwelveDays:
                    break;

                default:
                    runRule = false;
                    break;
                }
            }
            //Event > 30 days
            else
            {
                int day = GetDayForUnbroudcast(sug);

                switch (day)
                {
                //Second day -> add 5% to price
                case 2 + ThirtyDays:
                    sug.IncreasePrice(percentage: Five);
                    break;

                //Third day -> add 10% to price
                case 3 + ThirtyDays:
                    sug.IncreasePrice(percentage: Ten);
                    break;

                //Fourth day or fifth day -> add 15% to price
                case 4 + ThirtyDays:
                case 5 + ThirtyDays:
                    sug.IncreasePrice(percentage: Fifteen);
                    break;

                //Sixth day -> add 20% to price
                case 6 + ThirtyDays:
                    sug.IncreasePrice(percentage: Twenty);
                    break;

                //Seventh day - Unbroadcast
                case 7 + ThirtyDays:
                    break;

                default:
                    runRule = false;
                    break;
                }
            }
            SaveResultToDatabase(sug, results, runRule);
        }
Ejemplo n.º 4
0
        //LOWER
        private void Lower(SourceSug sug, Result results)
        {
            if (sug == null)
            {
                throw new ArgumentNullException(nameof(sug));
            }

            sug.CheckRequiredFields(price: false, sugPrice: true, runDate: false, eventDate: false);

            //Any listings that are suggested for lower than $30 should be priced at $30, don’t run rule
            if (sug.SugPrice < MinPrice)
            {
                sug.Price = MinPrice;

                SaveResultToDatabase(sug, results, runRule: true);

                OnEventHappened(SuggestionRulesStrings.Lower + ": SugPrice is lower than " + MinPrice + "$! Price was set to " + MinPrice + "$.");
                return;
            }

            sug.CheckRequiredFields(price: true, sugPrice: false, runDate: false, eventDate: true);

            var runRule = false;

            //Event within 7 days
            if (sug.EventDateWithin(SevenDays))
            {
                if (
                    //Change < $10 and sug has LOWER for past 2 days
                    (sug.ChangeLower(LowestChange) && HasForPast(TwoDays, sug))
                    //Change $10 ‐ $30 and sug has LOWER $10‐$30 for past 3 days
                    || (sug.ChangeHigherOrEquals(LowestChange) && sug.ChangeLowerOrEquals(HighestChange) &&
                        HasForPast(ThreeDays, sug, LowestChange, HighestChange)))
                {
                    runRule = true;
                }
            }
            //Event 7‐30 days
            else if (sug.EventDateFromTo(SevenDays, ThirtyDays))
            {
                if (
                    //Change < $10 and sug has LOWER for past 3 days
                    (sug.ChangeLower(LowestChange) && HasForPast(ThreeDays, sug))
                    //Change $10 ‐ $30 and sug has LOWER $10‐$30 for past 4 days
                    || (sug.ChangeHigherOrEquals(LowestChange) && sug.ChangeLowerOrEquals(HighestChange) &&
                        HasForPast(FourDays, sug, LowestChange, HighestChange))
                    //Change > $30 and sug has LOWER +/‐ $10 for past 7 days
                    || (sug.ChangeHigher(HighestChange) && HasForPast(SevenDays, sug, LowestChange)))
                {
                    runRule = true;
                }
            }
            //Event > 30 days
            else
            {
                if (
                    //Change < $10 and sug has LOWER for past 5 days
                    (sug.ChangeLower(LowestChange) && HasForPast(FiveDays, sug))
                    //Change $10 ‐ $30 and sug has LOWER $10‐$30 for past 7 days
                    || (sug.ChangeHigherOrEquals(LowestChange) && sug.ChangeLowerOrEquals(HighestChange) &&
                        HasForPast(SevenDays, sug, LowestChange, HighestChange))
                    //Change > $30 and sug has LOWER +/‐ $10 for past 10 days
                    || (sug.ChangeHigher(HighestChange) && HasForPast(TenDays, sug, LowestChange)))
                {
                    runRule = true;
                }
            }
            SaveResultToDatabase(sug, results, runRule);
        }