本文整理汇总了C#中UserRepository.GetFiltered方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.GetFiltered方法的具体用法?C# UserRepository.GetFiltered怎么用?C# UserRepository.GetFiltered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository.GetFiltered方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public void Register(User user)
{
if (user == null)
throw new ArgumentNullException("user");
using (UserRepository userRepository = new UserRepository())
{
if (userRepository.CheckAccountExistByName(user.UserName))
{
// throw account name exists exception
throw new AccountIsExistException(string.Format(Resource.UserMessages.ex_AccountExist, user.UserName));
}
var accounts = userRepository.GetFiltered(a => a.Email == user.Email);
if (accounts.Count<User>() > 0)
{
// throw email exists exception
throw new AccountEmailExistException(string.Format(Resource.UserMessages.ex_EmailExist, user.Email));
}
userRepository.Add(user);
userRepository.Commit();
}
}
示例2: RegisterTest
public void RegisterTest()
{
IUserService accountSrv = new UserService();
UserAppService target = new UserAppService(accountSrv);
using (UserRepository accountRepository = new UserRepository())
{
var accounts = accountRepository.GetFiltered(a => a.AccountName == "zhangsan");
if (accounts != null && accounts.ToList<User>().Count > 0)
{
var existedAccount = accounts.Single<User>
(a => a.AccountName == "zhangsan");
if (existedAccount != null)
{
accountRepository.Remove(existedAccount);
accountRepository.Commit();
}
}
var accountAdd = User.CreateAccount(new Guid("D1111C18-A0BD-480B-99CA-AAF50B2D1818"), "zhangsan", "123456", "[email protected]",
120, false, "310123199009091244", "张三", "", true, false);
target.Register(accountAdd);
var accountInRepository = accountRepository.Get(accountAdd.Id);
Assert.AreEqual(accountInRepository.AccountName, accountAdd.AccountName);
}
}