Exemplo n.º 1
0
 public void AddSingleStatistic(StatisticDTO item)
 {
     using (UsageStatisticsModel db = new UsageStatisticsModel()) {
         db.UsageStatistics.Add(new UsageStatistics(item));
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
        public void RemoveLastRow()
        {
            using (UsageStatisticsModel db = new UsageStatisticsModel())
            {
                var row = db.UsageStatistics.OrderByDescending(x => x.Time).FirstOrDefault();

                if (row != null)
                {
                    db.UsageStatistics.Remove(row);
                    db.SaveChanges();
                }
            }
        }
Exemplo n.º 3
0
 public IEnumerable <StatisticDTO> GetAllStatistics()
 {
     using (UsageStatisticsModel db = new UsageStatisticsModel()) {
         return(db.UsageStatistics.Select(x => new StatisticDTO()
         {
             IdUsageStatistics = x.IdUsageStatistics,
             Time = x.Time,
             Type = x.Type,
             BaseUnit = x.BaseUnit,
             BaseValue = x.BaseValue,
             ConvertedUnit = x.ConvertedUnit,
             ConvertedValue = x.ConvertedValue
         }).ToList());
     }
 }