Beispiel #1
0
        public void PushForward(Route route, StopGroup stop)
        {
            lock (ctx)
            {
                var originalEntry = ctx.FavoriteEntries.Where(e => e.RouteID == route.ID && e.StopID == stop.ID).Single();
                var nextEntry     = ctx.FavoriteEntries.Where(e => e.Position > originalEntry.Position).MinBy(e => e.Position.Value);
                if (nextEntry != null)
                {
                    int?nextPos = nextEntry.Position;

                    nextEntry.Position     = originalEntry.Position;
                    originalEntry.Position = nextPos;
                    ctx.Update(nextEntry);
                    ctx.Update(originalEntry);
                }
            }
        }
Beispiel #2
0
 public void AddTimetableHistory(Route route, StopGroup stop, int weight = 1)
 {
     lock (ctx)
     {
         DateTime now = DateTime.Now;
         var      q   = from e in ctx.HistoryEntries
                        where e.RouteID == route.ID && e.StopID == stop.ID
                        select e;
         HistoryEntry entry = q.SingleOrDefault(x => x.IsActive(now));
         if (entry != null)
         {
             entry.RawCount = entry.RawCount + (weight << FloatingBits);
             ctx.Update(entry);
         }
         else
         {
             entry = new HistoryEntry(now)
             {
                 Route = route, Stop = stop, RawCount = weight << FloatingBits
             };
             ctx.Insert(entry);
         }
     }
 }