public async Task <IActionResult> Read(int userId, CancellationToken cancellationToken) { var requestResult = new RequestResult <UserUpdate>() { Model = new UserUpdate() }; var requestResultUser = await _iBusinessUsers.Read(userId, cancellationToken); requestResult.Add(requestResultUser); if (requestResultUser.Succeeded) { requestResult.Model.User = requestResultUser.Model; var requestResultRole = await _iBusinessRoles.Read(cancellationToken); requestResult.Add(requestResultRole); if (requestResultRole.Succeeded) { requestResult.Model.Roles = requestResultRole.Model; } return(Ok(requestResult)); } else { return(NotFound(requestResult)); } }
public async Task Read_TestPageLimitRestriction(int pages, bool succeeded) { _moqDataUsers.Setup(a => a.Read(It.IsAny <int>(), It.IsAny <int>())).Returns( Task.FromResult( new Tuple <List <EntityUser>, int>(new List <EntityUser>(), 1) )); _iBusinessUsers = new BusinessUsers(_imapper, _moqRepoBase.Object, _moqDataUsers.Object); _pageFilter.ItemsPerPage = pages; var requestResult = await _iBusinessUsers.Read(_pageFilter, default); Assert.Equal(succeeded, requestResult.Succeeded); if (succeeded) { Assert.Equal(pages, requestResult.Model.ItemsPerPage); } else { Assert.Equal(100, requestResult.Model.ItemsPerPage); } }