using System; using System.Linq; using JetBrains.Annotations; using NHibernate; using Portoa.NHibernate; using Portoa.Persistence; namespace VideoGameQuotes.Api.Persistence { public interface IUserRepository : IRepository { [CanBeNull] User FindByUsername(string name); [CanBeNull] User FindByIpAddress(string ipAddress); } public class UserRepository : NHibernateRepository, 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); } } }