Пример #1
0
 public List <Refuel> GetLatestRefuels(int amount)
 {
     try
     {
         return(refuelsCollection.Aggregate().SortByDescending((a) => a["date"]).Limit(amount)
                .ToList().Select(x => Refuel.Parse(x)).ToList());
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Пример #2
0
 public List <Refuel> GetLatestRefuelsByTime(int hours)
 {
     try
     {
         return(refuelsCollection.Aggregate().SortByDescending((a) => a["date"]).ToList()
                .FindAll(x => (getTime() - DateTime.Parse(x["date"].AsString)).TotalHours <= hours)
                .ToList().Select(x => Refuel.Parse(x)).ToList());
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Пример #3
0
 private void ReadDataRefuel(int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         if (!refuelFile.EndOfStream)
         {
             waitingRefuel.Add(Refuel.Parse(refuelFile.ReadLine()));
         }
         else
         {
             return;
         }
     }
 }
Пример #4
0
 public async void AddRefuel(Refuel data)
 {
     await refuelsCollection.InsertOneAsync(Refuel.Parse(data));
 }