private double?GetProgress(PromotionDetail promotionDetail, PromotionProgressDetail progressDetail) { if (promotionDetail.TriggerSettings.Type == PromotionTriggerTypes.RideCount) { return((progressDetail == null || progressDetail.RideCount == null) ? 0 : progressDetail.RideCount); } else if (promotionDetail.TriggerSettings.Type == PromotionTriggerTypes.AmountSpent) { return((progressDetail == null || progressDetail.AmountSpent == null) ? 0.0 : progressDetail.AmountSpent); } return(null); }
public void Handle(UserAddedToPromotionWhiteList_V2 @event) { using (var context = _contextFactory.Invoke()) { foreach (var accountId in @event.AccountIds) { var promotionProgressDetail = context.Set <PromotionProgressDetail>().Find(accountId, @event.SourceId); if (promotionProgressDetail == null) { promotionProgressDetail = new PromotionProgressDetail { AccountId = accountId, PromoId = @event.SourceId }; context.Save(promotionProgressDetail); } promotionProgressDetail.LastTriggeredAmount = @event.LastTriggeredAmount; } context.SaveChanges(); } }