public async Task OnGet(string id) { startDate = DateTime.Now.AddHours(-3); endDate = DateTime.Now; if (id != null) { WellName = id; Brunnar.Add(id); IEnumerable <ActivityPerRow> wells = await GetWellRowsAsync(); DateNow = DateTime.Now; // Latest activity LatestActivity = wells.OrderByDescending(a => a.TimeUp).Take(1); // Number of activity last hour LatestHour = CountRows(wells, -1); // Number of activity last 3 hour Latest3Hour = CountRows(wells, -3); // Number of activity last 24 hour Latest24Hour = CountRows(wells, -24); PremisesPerWell = await GetPropertiesAsync(); PremisesText = GetPremisesText(); } }
private async Task <IEnumerable <ActivityPerRow> > GetWellRowsAsync() { // return await _context.Activities.Where(a => Brunnar.Contains(a.Address) && a.Time >= endDate.AddDays(-2) && a.Time <= endDate).ToListAsync(); return(await _context.ActivityPerRows.Where(a => Brunnar.Contains(a.Address)) .Where(a => a.TimeUp >= endDate.AddDays(-2) && a.TimeUp <= endDate) .ToListAsync()); }
private async Task <IEnumerable <PremisesPerWellViewModel> > GetPropertiesAsync() { return(await _context.Premises .Include(a => a.Well) //.Where(a => a.Well.WellName == WellName) .Where(a => Brunnar.Contains(a.Well.WellName)) .Select(a => new PremisesPerWellViewModel { WellName = a.Well.WellName, Property = a.Property, Address = a.Address }) .OrderBy(a => a.WellName) .ToListAsync()); }