/// <summary> /// update the history of hit through the caller ( investors) /// </summary> /// <param name="investor"></param> /// <param name="sellingStock"></param> /// <param name="tradeTrigger"></param> private void updateNotificationHistory(IInvestor investor, TradeTriggerType tradeTriggerType, ITradeTrigger tradeTrigger) { var histoiry = NotificationHistory.Where(h => h.Investor == investor.InvestorName && h.TradeTriggerType == tradeTriggerType && h.TriggerName == tradeTrigger.TriggerName).FirstOrDefault(); if (histoiry == null) { NotificationHistory.Add(new Notification() { Investor = investor.InvestorName, TradeTriggerType = tradeTriggerType, TriggerName = tradeTrigger.TriggerName, Counter = 1 }); } else { histoiry.Counter = histoiry.Counter + 1; } }
/// <summary> /// check how oftne we have to send the notification throuight the caller ( investor), e.g: once, unlimited, /// we can improve this by adding some more meta data in the notification interface like data, time, week,... /// then we could manage all diffrent senarioes like once per day m once per week , or all other combination that investor will inject by the time that /// set the investor in the stocket object or later attch new one... /// </summary> /// <param name="investor"></param> /// <param name="tradeTrigger"></param> /// <returns></returns> private bool hasPermissionToSendNotification(IInvestor investor, ITradeTrigger tradeTrigger) { if (tradeTrigger.NotificationType == ReceiveNotificationType.Unlimited) { return(true); } else if (tradeTrigger.NotificationType == ReceiveNotificationType.Once) { if (NotificationHistory.Where(h => h.Investor == investor.InvestorName && h.TradeTriggerType == tradeTrigger.TradeTriggerType && h.TriggerName == tradeTrigger.TriggerName).FirstOrDefault() == null) { return(true); } } return(false); }