public void QueryOrganizationUser_Test() { var transactionMock = new Mock <IDbContextTransaction>(); database.Setup(d => d.BeginTransaction()).Returns(transactionMock.Object); context.Setup(e => e.Database).Returns(database.Object); SetupOrganizationUsersDbSet(new List <OrganizationUserEntity>(new[] { new OrganizationUserEntity { OrganizationUserEntityId = 5, OrganizationId = 1, UserType = 2, FirstName = "user0", LastName = "User0", Email = "*****@*****.**", IsActive = true, TransactionId = "abc0" } })); var model = new QueryOrganizationUserCriteria { UserType = 2, //OrganizationIds = {1} }; var res = organizationUserRepository.QueryOrganizationUser(model); Assert.True(res.Total > 0); }
public Result <QueryOrganizationUserResult> QueryOrganizationUser(QueryOrganizationUserCriteria criteria) { var queryOrganizationUsersResult = this.organizationUserRepository.QueryOrganizationUser(criteria); if (queryOrganizationUsersResult is null) { return(new Result <QueryOrganizationUserResult>(new InvalidOrganizationUserIdError())); } return(new Result <QueryOrganizationUserResult>(queryOrganizationUsersResult)); }
public QueryOrganizationUserResult QueryOrganizationUser(QueryOrganizationUserCriteria model) { //var orgUsers = context.OrganizationUsers; IQueryable <OrganizationUserEntity> queryable = this .GetBaseOrganizationUserEntity() .Include(t => t.Profile) .ThenInclude(p => p.ProfileValues) .ThenInclude(pv => pv.ProfileParameter) .Where(t => t.DeletedAt == null && t.RollbackedAt == null) ; if (model.OrganizationIds != null && model.OrganizationIds.Count > 0) { queryable = queryable .Where(e => model.OrganizationIds.Contains(e.OrganizationId)) .Include(t => t.Profile) .ThenInclude(p => p.ProfileValues) .ThenInclude(pv => pv.ProfileParameter) ; } if (model.UserType >= 1) { queryable = queryable .Where(e => e.UserType == model.UserType) .Include(t => t.Profile) .ThenInclude(p => p.ProfileValues) .ThenInclude(pv => pv.ProfileParameter) ; } var queryOrganizationUserResult = new QueryOrganizationUserResult { OrganizationUsersData = queryable.Select(p => this.mapper.Map <OrganizationUserListModel>(p)).ToList(), Total = queryable.Count() }; return(queryOrganizationUserResult); }