vgquotes/Src/VideoGameQuotes.Api/Persistence/IUserRepository.cs
tmont 9a1f0347c0 * tests for user provider
* username is no longer required
* added ip address property to user
2011-02-10 21:04:13 +00:00

28 lines
756 B
C#

using System;
using System.Linq;
using JetBrains.Annotations;
using NHibernate;
using Portoa.NHibernate;
using Portoa.Persistence;
namespace VideoGameQuotes.Api.Persistence {
public interface IUserRepository : IRepository<User> {
[CanBeNull]
User FindByUsername(string name);
[CanBeNull]
User FindByIpAddress(string ipAddress);
}
public class UserRepository : NHibernateRepository<User>, IUserRepository {
public UserRepository(ISession session) : base(session) { }
public User FindByUsername(string name) {
return Records.FirstOrDefault(user => user.Username == name);
}
public User FindByIpAddress(string ipAddress) {
return Records.FirstOrDefault(user => user.IpAddress == ipAddress);
}
}
}