public async Task<PaginatedList<Monthly>> GetMonthlys(string start, string end, int pageIndex, int pageSize) { //var source = DbSet // .Where(x => x.Date >= DateTime.Parse(start) && x.Date <= DateTime.Parse(end).AddMonths(1).AddSeconds(-1)) // .GroupBy(x => x.Date.ToString("yyyy-MM"), (k, v) => // new Monthly // { // ID = Guid.NewGuid().ToString(), // Month = k, // Cost = v.Sum(x => x.Cost) // }); //int count = await source.CountAsync(); var source = DbSet .Where(x => x.Date >= DateTime.Parse(start) && x.Date <= DateTime.Parse(end).AddMonths(1).AddSeconds(-1)) .GroupBy(x => AccountContext.ExtractMonth(x.Date)) .Select(g => new Monthly { ID = Guid.NewGuid().ToString(), Month = g.Key, Cost = g.Sum(x => x.Cost) }); int count = await source.CountAsync(); List<Monthly> months = null; if (count > 0) { months = await source.OrderBy(x => x.Month).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync(); } return new PaginatedList<Monthly>(pageIndex, pageSize, count, months ?? new List<Monthly>()); }
public static void Initialize(AccountContext context) { context.Database.EnsureCreated(); if (context.Manifests.Any()) { return; } }
public ManifestRepository(AccountContext context) : base(context) { }
public YearlyRepository(AccountContext context) { _context = context; }
public MonthlyRepository(AccountContext context) { _context = context; }
public DailyRepository(AccountContext context) { _context = context; }
public DailyRepository(AccountContext context) : base(context) { }
public ManifestRepository(AccountContext context) { _context = context; }