本文整理汇总了C#中IUsersRepository.GetUsersCount方法的典型用法代码示例。如果您正苦于以下问题:C# IUsersRepository.GetUsersCount方法的具体用法?C# IUsersRepository.GetUsersCount怎么用?C# IUsersRepository.GetUsersCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUsersRepository
的用法示例。
在下文中一共展示了IUsersRepository.GetUsersCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUsersPaginated
public Users GetUsersPaginated(UserFilter filterData, Pagination pagination, IUsersRepository repository)
{
ValidateRepositoryInstance(repository);
if(pagination == null)
pagination = new Pagination().SetRequestData(int.MaxValue, 0);
this.Pagination = pagination;
var usersCount = repository.GetUsersCount(filterData);
this.Pagination.SetResponseData(0);
if (usersCount == 0)
{
this.Pagination.SetResponseData(0);
return this;
}
var users = repository.GetUsers(filterData, pagination.PageSize, this.Pagination.CurrentPage * this.Pagination.PageSize);
this.UsersList = users;
return this;
}
示例2: ValidateExistentEmail
private void ValidateExistentEmail(IUsersRepository repository)
{
var filter = new UserFilter().SetEmail(this.Email);
if (string.IsNullOrEmpty(this.Id))
{
var count = repository.GetUsersCount(filter);
if(count > 0)
throw new ArgumentException("There is another user with the same email");
return;
}
var users = repository.GetUsers(filter, 2, 0);
if (users == null || !users.Any())
return;
if (users.All(u => u.Id == this.Id))
return;
throw new ArgumentException("There is another user with the same email");
}