public int GetFeedsCount(string ticket, TransitFeedQueryOptions options) { using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection())) { ISession session = DBlog.Data.Hibernate.Session.Current; CountQuery q = new CountQuery(session, typeof(DBlog.Data.Feed), "Feed"); if (options != null) { options.Apply(q); } return q.Execute<int>(); } }
public List<TransitFeed> GetFeeds(string ticket, TransitFeedQueryOptions options) { using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection())) { ISession session = DBlog.Data.Hibernate.Session.Current; ICriteria cr = session.CreateCriteria(typeof(Feed)); if (options != null) { options.Apply(cr); } IList<Feed> list = cr.List<Feed>(); List<TransitFeed> result = new List<TransitFeed>(list.Count); bool fAdmin = ManagedLogin.IsAdministrator(session, ticket); foreach (Feed obj in list) { if (!fAdmin) { obj.Username = string.Empty; obj.Password = string.Empty; } result.Add(new TransitFeed(obj)); } return result; } }