public int Bind(Route route, StopGroup stop) { lock (ctx) { TileEntry entry = new TileEntry { Route = route, Stop = stop }; ctx.TileEntries.InsertOnSubmit(entry); ctx.SubmitChanges(); return(entry.EntryID); } }
public void Add(Route route, StopGroup stop) { lock (ctx) { if (Contains(route, stop)) { throw new DuplicateKeyException(null); } int position = 1; if (ctx.FavoriteEntries.FirstOrDefault() != null) { position = ctx.FavoriteEntries.Max(fav => fav.Position ?? 0) + 1; } FavoriteEntry entry = new FavoriteEntry { Route = route, Stop = stop, Position = position }; ctx.FavoriteEntries.InsertOnSubmit(entry); ctx.SubmitChanges(); } }
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.ToList().SingleOrDefault(x => x.IsActive(now)); if (entry != null) { entry.RawCount = entry.RawCount + (weight << FloatingBits); } else { entry = new HistoryEntry(now) { Route = route, Stop = stop, RawCount = weight << FloatingBits }; ctx.HistoryEntries.InsertOnSubmit(entry); } ctx.SubmitChanges(); } }