public IEnumerable <IOutgoingPayment> GetOutgoingPayments(IOutgoingPaymentFilter outgoingPaymentFilter) { Expression <Func <IOutgoingPayment, bool> > predicate = payment => IsAccountMatch(outgoingPaymentFilter, payment) && IsTypeMatch(outgoingPaymentFilter, payment) && IsFromDateMatch(outgoingPaymentFilter, payment) && IsToDateMatch(outgoingPaymentFilter, payment); return(dataStore.OutgoingPayments.AsQueryable().Where(predicate.Compile())); }
private IObservable <OutgoingPaymentsResult> CreateOutgoingPaymentsObservable() { return(Observable.Return(GetSelectedAccountIds()) .Select(accountIds => { IOutgoingPaymentFilter outgoingPaymentFilter = CreateOutcomingPaymentFilter(accountIds); IReadOnlyCollection <IOutgoingPayment> outgoingPayments = outgoingPaymentRepository.GetOutgoingPayments(outgoingPaymentFilter).ToList(); return new OutgoingPaymentsResult(outgoingPaymentFilter, outgoingPayments); })); }
private static bool IsTypeMatch(IOutgoingPaymentFilter paymentFilter, IOutgoingPayment payment) { return(paymentFilter.Types.Contains(payment.Type)); }
private static IDictionary <string, float> GetAmountPercentData(IReadOnlyCollection <IOutgoingPayment> outgoingPayments, IOutgoingPaymentFilter outgoingPaymentFilter) { Dictionary <string, List <IOutgoingPayment> > incomingPaymentWithType = outgoingPaymentFilter.Types.ToDictionary(type => type.ToString(), type => outgoingPayments.Where(payment => payment.Type == type).ToList()); float totalAmount = incomingPaymentWithType.Sum(paymentGroup => paymentGroup.Value.Sum(payment => payment.Amount)); return(incomingPaymentWithType.ToDictionary(paymentGroup => paymentGroup.Key, paymentGroup => paymentGroup.Value.Sum(payment => payment.Amount) * 100 / totalAmount)); }
public IChartPairData GetChartData(IReadOnlyCollection <IOutgoingPayment> outgoingPayments, IOutgoingPaymentFilter outgoingPaymentFilter) { return(new ChartPairData { Ids = outgoingPayments.Select(payment => payment.Id).ToList(), AmountPercentData = GetAmountPercentData(outgoingPayments, outgoingPaymentFilter), AmountDateData = GetAmountTimeData(outgoingPayments, outgoingPaymentFilter) }); }
public OutgoingPaymentsResult(IOutgoingPaymentFilter outgoingPaymentFilter, IReadOnlyCollection <IOutgoingPayment> outgoingPayments) { OutgoingPaymentFilter = outgoingPaymentFilter; OutgoingPayments = outgoingPayments; }