2011-02-17 20:55:47 +00:00
|
|
|
|
using System.Linq;
|
2011-02-10 21:04:13 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2011-02-10 04:39:59 +00:00
|
|
|
|
using NHibernate;
|
|
|
|
|
using Portoa.NHibernate;
|
|
|
|
|
using Portoa.Persistence;
|
|
|
|
|
|
|
|
|
|
namespace VideoGameQuotes.Api.Persistence {
|
|
|
|
|
public interface IUserRepository : IRepository<User> {
|
2011-02-10 21:04:13 +00:00
|
|
|
|
[CanBeNull]
|
2011-02-10 04:39:59 +00:00
|
|
|
|
User FindByUsername(string name);
|
2011-02-10 21:04:13 +00:00
|
|
|
|
|
|
|
|
|
[CanBeNull]
|
|
|
|
|
User FindByIpAddress(string ipAddress);
|
2011-02-10 04:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UserRepository : NHibernateRepository<User>, IUserRepository {
|
|
|
|
|
public UserRepository(ISession session) : base(session) { }
|
|
|
|
|
|
|
|
|
|
public User FindByUsername(string name) {
|
|
|
|
|
return Records.FirstOrDefault(user => user.Username == name);
|
|
|
|
|
}
|
2011-02-10 21:04:13 +00:00
|
|
|
|
|
|
|
|
|
public User FindByIpAddress(string ipAddress) {
|
|
|
|
|
return Records.FirstOrDefault(user => user.IpAddress == ipAddress);
|
|
|
|
|
}
|
2011-02-10 04:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|