Esempio n. 1
0
    static IQueryable <Transaction> GetTransactionsFilter(CocaBotPoolContext db, int proposedAmount, string to, string from, string detail, int tax, long start, long end)
    {
        IQueryable <Transaction> search = db.Transactions.AsQueryable();

        if (to != "")
        {
            search = search.Where(x => x.ToAccount == to);
        }
        if (from != "")
        {
            search = search.Where(x => x.FromAccount == from);
        }
        if (tax != -1)
        {
            search = search.Where(x => (int)x.Tax == tax);
        }
        if (detail != "")
        {
            search = search.Where(x => x.Detail.Contains(detail));
        }
        if (start != -1)
        {
            search = search.Where(x => x.Timestamp > start);
        }
        if (end != -1)
        {
            search = search.Where(x => x.Timestamp < end);
        }

        int amount = proposedAmount switch
        {
            -1 => 100,
            > 100000 => 100000,
            _ => proposedAmount
        };

        return(search.OrderByDescending(x => x.Count).Take(amount));
    }
}
Esempio n. 2
0
 static async Task <decimal> SumFilter(CocaBotPoolContext db, int amount = -1, string to = "", string from = "", string detail = "", int tax = -1, long start = -1, long end = -1)
 => await GetTransactionsFilter(db, amount, to, from, detail, tax, start, end).SumAsync(x => x.Amount);
Esempio n. 3
0
 static async Task <List <Transaction> > Filter(CocaBotPoolContext db, int amount = -1, string to = "", string from = "", string detail = "", int tax = -1, long start = -1, long end = -1)
 => await GetTransactionsFilter(db, amount, to, from, detail, tax, start, end).ToListAsync();