private async Task <Result <Select2Result <Select2Item> > > GetPaginatedSelect2Result <TResult>(
            ISelectSpecificationBuilder <AuditEntity, TResult> specificationBuilder,
            Select2Request select2Request)
        {
            int count = await _auditDAO.Count(specificationBuilder.Build());

            var selectSpecification = specificationBuilder
                                      .Paginate(select2Request.GetPageStart(), select2Request.GetPageLenght())
                                      .Build();

            List <TResult> objectTypes = await _auditDAO.Get(selectSpecification);

            Select2Result <Select2Item> select2Result = new Select2Result <Select2Item>(
                objectTypes
                .Select(x => new Select2Item(
                            id: x?.ToString(),
                            text: x?.ToString()))
                .ToList(),
                pagination: select2Request.IsMore(count));

            return(Result.Ok(select2Result));
        }
        public async Task <Result <DataTableResult <GroupInviteTableModel> > > Get(string groupId, DataTableRequest dataTableRequest)
        {
            ValidationResult validationResult = _dataTableRequestValidator.Validate(dataTableRequest);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invalid {nameof(DataTableRequest)} model");
                return(Result.Fail <DataTableResult <GroupInviteTableModel> >(validationResult.ToResultError()));
            }

            ISelectSpecificationBuilder <InviteEntity, GroupInviteTableModel> specificationBuilder = SpecificationBuilder
                                                                                                     .Create <InviteEntity>()
                                                                                                     .Where(x => x.GroupId == groupId)
                                                                                                     .SearchByEmail(dataTableRequest.Search)
                                                                                                     .OrderByDessending(x => x._CreatedDate)
                                                                                                     .Select(x => new GroupInviteTableModel(
                                                                                                                 x.Id,
                                                                                                                 x.Email,
                                                                                                                 x.GroupRole.Name,
                                                                                                                 x.Status.GetDescription(),
                                                                                                                 x.ExpiresAt.ToString("o")));

            IBaseSpecification <InviteEntity, GroupInviteTableModel> countSpecification = specificationBuilder.Build();
            IBaseSpecification <InviteEntity, GroupInviteTableModel> dataSpecification  = specificationBuilder
                                                                                          .Paginate(dataTableRequest.Start, dataTableRequest.Length)
                                                                                          .Build();

            int count = await _inviteDAO.Count(countSpecification);

            var data = await _inviteDAO.Get(dataSpecification);


            DataTableResult <GroupInviteTableModel> dataTableResult = new DataTableResult <GroupInviteTableModel>(
                draw: dataTableRequest.Draw,
                recordsTotal: count,
                recordsFiltered: count,
                data: data);

            return(Result.Ok(dataTableResult));
        }
예제 #3
0
        public async Task <Result <DataTableResult <GroupUserTableModel> > > Get(string groupId, DataTableRequest request)
        {
            ValidationResult validationResult = _dataTableValidator.Validate(request);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invalid DataTableRequest model");
                return(Result.Fail <DataTableResult <GroupUserTableModel> >(validationResult.ToResultError()));
            }

            ISelectSpecificationBuilder <GroupUserEntity, GroupUserTableModel> specificationBuilder = SpecificationBuilder
                                                                                                      .Create <GroupUserEntity>()
                                                                                                      .Where(x => x.GroupId == groupId)
                                                                                                      .SearchByUsernameEmailId(request.Search)
                                                                                                      .OrderByDessending(x => x._CreatedDate)
                                                                                                      .Select(x => new GroupUserTableModel(
                                                                                                                  x.Id,
                                                                                                                  x.UserId,
                                                                                                                  x.User.UserName,
                                                                                                                  x.User.Email,
                                                                                                                  x.RoleId,
                                                                                                                  x.Role.Name));

            IBaseSpecification <GroupUserEntity, GroupUserTableModel> countSpecification = specificationBuilder.Build();
            IBaseSpecification <GroupUserEntity, GroupUserTableModel> dataSpecification  = specificationBuilder
                                                                                           .Paginate(request.Start, request.Length)
                                                                                           .Build();

            int count = await _groupUserDAO.Count(countSpecification);

            List <GroupUserTableModel> groupUsers = await _groupUserDAO.Get(dataSpecification);

            DataTableResult <GroupUserTableModel> dataTableResult = new DataTableResult <GroupUserTableModel>(
                draw: request.Draw,
                recordsTotal: count,
                recordsFiltered: count,
                data: groupUsers);

            return(Result.Ok(dataTableResult));
        }
예제 #4
0
        public async Task <Result <DataTableResult <GroupAttributeTableModel> > > Get(string groupId, DataTableRequest dataTableRequest)
        {
            ValidationResult validationResult = _dataTableValidator.Validate(dataTableRequest);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invalid {nameof(dataTableRequest)} model");
                return(Result.Fail <DataTableResult <GroupAttributeTableModel> >(validationResult.ToResultError()));
            }

            ISelectSpecificationBuilder <GroupAttributeEntity, GroupAttributeTableModel> specificationBuilder = SpecificationBuilder
                                                                                                                .Create <GroupAttributeEntity>()
                                                                                                                .Where(x => x.GroupId == groupId)
                                                                                                                .SearchByKey(dataTableRequest.Search)
                                                                                                                .OrderByDessending(x => x._CreatedDate)
                                                                                                                .Select(x => new GroupAttributeTableModel(
                                                                                                                            x.Id,
                                                                                                                            x.Key,
                                                                                                                            x.Value));

            IBaseSpecification <GroupAttributeEntity, GroupAttributeTableModel> countSpecification = specificationBuilder.Build();
            IBaseSpecification <GroupAttributeEntity, GroupAttributeTableModel> dataSpecification  = specificationBuilder
                                                                                                     .Paginate(dataTableRequest.Start, dataTableRequest.Length)
                                                                                                     .Build();

            int count = await _groupAttributeDAO.Count(countSpecification);

            List <GroupAttributeTableModel> data = await _groupAttributeDAO.Get(countSpecification);

            DataTableResult <GroupAttributeTableModel> dataTableResult = new DataTableResult <GroupAttributeTableModel>(
                draw: dataTableRequest.Draw,
                recordsTotal: count,
                recordsFiltered: count,
                data: data);

            return(Result.Ok(dataTableResult));
        }