vgquotes/Src/VideoGameQuotes.Api/Persistence/IUserRepository.cs

28 lines
756 B
C#
Raw Normal View History

using System;
using System.Linq;
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> {
[CanBeNull]
2011-02-10 04:39:59 +00:00
User FindByUsername(string name);
[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);
}
public User FindByIpAddress(string ipAddress) {
return Records.FirstOrDefault(user => user.IpAddress == ipAddress);
}
2011-02-10 04:39:59 +00:00
}
}