Пример #1
0
 public List <History> GetAllStatistics(int page = 0)
 {
     using (ConvertersHistoryDataContext context = new ConvertersHistoryDataContext())
     {
         List <History> history = context.History.Skip(page * 20).Take(20).ToList();
         return(history);
     }
 }
Пример #2
0
        public double GetStatisticAmount()
        {
            using (ConvertersHistoryDataContext context = new ConvertersHistoryDataContext())
            {
                List <History> history = context.History.ToList();

                return(history.Count);
            }
        }
Пример #3
0
 public List <History> GetHistoryStatistic(int year, int month, int day)
 {
     using (ConvertersHistoryDataContext context = new ConvertersHistoryDataContext())
     {
         DateTime       timeFrom = new DateTime(2021, 4, 21);
         DateTime       timeTo   = new DateTime(2021, 5, 21);
         List <History> history  = context.History.Where(x => x.UsageDate >= timeFrom && x.UsageDate >= timeTo).ToList();
         return(history);
     }
 }
Пример #4
0
 public void AddHistoryToDb(string ConverterName, string valueBefore, string valueAfter, string unitFrom = null, string unitTo = null)
 {
     using (ConvertersHistoryDataContext context = new ConvertersHistoryDataContext())
     {
         History history = new History();
         history.ConverterName = ConverterName;
         DateTime date = DateTime.Now;
         history.UsageDate   = date;
         history.valueBefore = valueBefore;
         history.valueAfter  = valueAfter;
         history.unitFrom    = unitFrom;
         history.unitTo      = unitTo;
         context.History.Add(history);
         context.SaveChanges();
     }
 }
Пример #5
0
 public List <History> getThreeMostPopularConversions()
 {
     using (ConvertersHistoryDataContext context = new ConvertersHistoryDataContext())
     {
         List <History> history = context.History
                                  .GroupBy(grp => grp.ConverterName)
                                  .OrderByDescending(item => item.Count())
                                  .Take(3)
                                  .Select(s => new History
         {
             ConverterName = s.Key,
             id            = s.Count()
         })
                                  .ToList();
         return(history);
     }
 }