Advertisement
Guest User

Untitled

a guest
May 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. public IEnumerable<ISession> GetSessions()
  2. {
  3. var result = new List<ISession>();
  4. SiteEntity currSite;
  5. try
  6. {
  7. using (var dbContext = new AuctionSiteDbContext(_connectionString))
  8. {
  9. currSite = dbContext.Sites
  10. .Where(x => x.Name.Equals(Name))
  11. .Include(x => x.Sessions.Select(y=> y.UserEntity))
  12. .FirstOrDefault();
  13. }
  14. if (currSite == null)
  15. throw new InvalidOperationException();
  16.  
  17. }
  18. catch (Exception e)
  19. {
  20. InCommon.ExceptionCatching(e, null);
  21. throw;
  22. }
  23. foreach (var sessionEntity in currSite.Sessions)
  24. {
  25. result.Add(new Session(this, _connectionString, _alarmClock, sessionEntity.SessionId, sessionEntity.ValidUntil, new User(_connectionString, this, _alarmClock, sessionEntity.UserEntity.Username)));
  26. }
  27. return result;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement