public Data GetByDay(long msSinceEpoch, int minutesOffset) { Guid userId; if (!UserIdRepository.TryGetUserId(out userId)) { return(new Data()); } DateTime utcStart = new DateTime(1970, 1, 1).AddTicks(msSinceEpoch * 10000); DateTime utcEnd = utcStart.AddDays(1); var repo = new UsageRepository(); var dataRows = repo.GetRows(userId, utcStart, utcEnd); var dailyUsage = dataRows.ToDaily(minutesOffset); var uiUsage = dailyUsage.ToUI(); return(uiUsage); }
public IEnumerable <TableData> GetByDay(long msSinceEpoch, int minutesOffset) { Guid userId; List <UsageRow> dataRows; if (!UserIdRepository.TryGetUserId(out userId)) { dataRows = new List <UsageRow>(); } else { DateTime utcStart = new DateTime(1970, 1, 1).AddTicks(msSinceEpoch * 10000); DateTime utcEnd = utcStart.AddDays(1); var repo = new UsageRepository(); dataRows = repo.GetRows(userId, utcStart, utcEnd); } return(dataRows.ToTableData()); }
public void Post(UserUsage usage) { var repo = new UsageRepository(); repo.Save(new UsageRow(usage)); }