public bool Logout(Credential cr) { Repo <User> ur = new UserRepo(); ICollection <User> ulist = ur.ReadAll(); User user = null; foreach (var el in ulist) { if (el.Credential.Username == cr.Username && el.Credential.Password == cr.Password) { user = el; } } if (user == null) { return(false); } Repo <Session> sessionRepo = new SessionRepo(); ICollection <Session> sessions = sessionRepo.ReadAll(); Session session = null; foreach (var el in sessions) { if (el.Username == user.Credential.Username) { session = el; } } if (session == null) { return(false); } return(sessionRepo.Delete(session)); }