28 lines
756 B
C#
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);
|
|
}
|
|
}
|
|
} |