public async Task <QueryResultModel <AccountEntity> > Query(AccountQueryModel model)
        {
            //model.PageModel = getQueryPageModel();

            var result = await _service.Query(model);

            return(result.Data);
        }
        public bool TryGetAccountByEmail(Email accountEmail, out AccountQueryModel account)
        {
            EmailToAccountMapQueryModel accountMap;

            if (_documentDbQueryModels.TryGet(accountEmail.ToString(), out accountMap))
            {
                account = GetAccount(accountMap.AccountId);
                return(true);
            }
            account = null;
            return(false);
        }
        public void ResettingTestDatabasesRemovesAccountQueryModels()
        {
            var accountQueryModel = new AccountQueryModel();
            ((ISingleAggregateQueryModel)accountQueryModel).SetId(Guid.NewGuid());

            using(Container.BeginScope())
            {
                Container.Resolve<IAccountManagementQueryModelUpdaterSession>().Save(accountQueryModel);
                Container.Resolve<IAccountManagementQueryModelUpdaterSession>().Get<AccountQueryModel>(accountQueryModel.Id);
            }

            Container.ResetTestDataBases();
            using(Container.BeginScope())
            {
                Assert.Throws<NoSuchDocumentException>(() => Container.Resolve<IAccountManagementQueryModelUpdaterSession>().Get<AccountQueryModel>(accountQueryModel.Id));
            }
        }
Пример #4
0
        public async Task <IResultModel <QueryResultModel <AccountEntity> > > Query(AccountQueryModel model)
        {
            var result = new ResultModel <QueryResultModel <AccountEntity> >();

            var data = await _accountRepository.Query(model);

            foreach (var item in data.Rows)
            {
                var roles = await _accountRoleRepository.QueryRole(item.Uid);

                item.Roles = roles.Select(r => new OptionResultModel {
                    Label = r.RoleName, Value = r.Id
                }).ToList();
            }


            return(result.Success(data));
        }
Пример #5
0
        public async Task <IResultModel> Query(AccountQueryModel model)
        {
            var result = new QueryResultModel <AccountEntity>
            {
                Rows  = await _accountRepository.Query(model),
                Total = model.TotalCount
            };

            foreach (var item in result.Rows)
            {
                var roles = await _accountRoleRepository.QueryRole(item.Id);

                item.Roles = roles.Select(r => new OptionResultModel {
                    Label = r.Name, Value = r.Id
                }).ToList();
            }

            return(ResultModel.Success(result));
        }
Пример #6
0
        public async Task <IList <AccountEntity> > Query(AccountQueryModel model)
        {
            var paging = model.Paging();
            var query  = Db.Find(m => m.Deleted == false && m.Type == model.Type);

            query.WhereIf(model.UserName.NotNull(), m => m.UserName.Contains(model.UserName));
            query.WhereIf(model.Name.NotNull(), m => m.Name.Contains(model.Name));
            query.WhereIf(model.Phone.NotNull(), m => m.Phone == model.Phone);
            query.WhereIf(model.Email.NotNull(), m => m.Email == model.Email);

            if (!paging.OrderBy.Any())
            {
                query.OrderByDescending(m => m.Id);
            }

            var list = await query.PaginationAsync(paging);

            model.TotalCount = paging.TotalCount;
            return(list);
        }
Пример #7
0
        public async Task <IResultModel> Query(AccountQueryModel model)
        {
            var result = new QueryResultModel <AccountQueryResultModel>();
            var paging = model.Paging();
            var list   = await _accountRepository.Query(paging, model.UserName, model.Name, model.Phone, model.Email);


            result.Rows  = _mapper.Map <List <AccountQueryResultModel> >(list);
            result.Total = paging.TotalCount;

            Parallel.ForEach(result.Rows, async item =>
            {
                var roles  = await _accountRoleRepository.QueryRole(item.Id);
                item.Roles = roles.Select(r => new OptionResultModel {
                    Label = r.Name, Value = r.Id
                }).ToList();
            });

            return(ResultModel.Success(result));
        }
        public async Task <QueryResultModel <AccountEntity> > Query(AccountQueryModel model)
        {
            var paging = model.Paging();
            var query  = dbSet.AsQueryable();

            if (model.status != null)
            {
                query = query.Where(a => a.Status == model.status);
            }
            if (!model.keyword.IsNull())
            {
                query = query.Where(a => a.LoginName.Contains(model.keyword) || a.Phone.Contains(model.keyword) || a.RealName.Contains(model.keyword));
            }

            if (!paging.OrderBy.Any())
            {
                query = query.OrderByDescending(m => m.CreatedTime);
            }
            return(await query.PaginationGetResult(paging));
        }
Пример #9
0
        public async Task <IList <AccountEntity> > Query(AccountQueryModel model)
        {
            var paging = model.Paging();
            var query  = Db.Find();

            query.WhereNotNull(model.Type, m => m.Type == model.Type.Value);
            query.WhereNotNull(model.UserName, m => m.UserName.Contains(model.UserName));
            query.WhereNotNull(model.Name, m => m.Name.Contains(model.Name));
            query.WhereNotNull(model.Phone, m => m.Phone == model.Phone);
            query.WhereNotNull(model.Email, m => m.Email == model.Email);

            var joinQuery = query.LeftJoin <TenantEntity>((x, y) => x.TenantId == y.Id);

            if (!paging.OrderBy.Any())
            {
                joinQuery.OrderByDescending((x, y) => x.Id);
            }
            //不适用租户过滤功能
            var list = await joinQuery.NotFilterTenant().PaginationAsync(paging);

            model.TotalCount = paging.TotalCount;
            return(list);
        }
Пример #10
0
 public Task <IResultModel> Query([FromQuery] AccountQueryModel model)
 {
     return(_service.Query(model));
 }