public async Task <List <IncomeOverviewModel> > HandleAsync(ListMonthIncome query) { using (ReadModelContext db = dbFactory.Create()) { var sql = db.Incomes .WhereUserKey(query) .Where(i => i.When.Month == query.Month.Month && i.When.Year == query.Month.Year); sql = ApplySorting(sql, query); sql = ApplyPaging(sql, query); List <IncomeOverviewModel> models = await sql .Select(i => i.ToOverviewModel(query)) .ToListAsync(); return(models); } }
public IncomeOverviewModel ToOverviewModel(ListMonthIncome query) => new IncomeOverviewModel( GuidKey.Create(Id, KeyFactory.Empty(typeof(Income)).Type), new Price(Amount, Currency), When, Description );