public override IQueryable <UserVM> GetSearchedModel(SearchPaginationRequest <UserVM> request)
        {
            IQueryable <UserVM> model = GetModel();

            string email = request?.SearchData?.Email;
            string id    = request?.SearchData?.Id;
            string name  = request?.SearchData?.Name;
            string role  = request?.SearchData?.Role;

            model = model.Where(u => u.IsDeleted != true);

            if (!string.IsNullOrEmpty(email))
            {
                model = model.Where(u => u.Email.Contains(email));
            }

            if (!string.IsNullOrEmpty(id))
            {
                model = model.Where(u => u.Id == id);
            }

            if (!string.IsNullOrEmpty(name))
            {
                model = model.Where(u => u.Name.Contains(name));
            }

            if (!string.IsNullOrEmpty(role))
            {
                model = model.Where(u => u.Role.Contains(role));
            }

            return(model);
        }
Пример #2
0
        /**
         *  Order Data
         **/
        public virtual IOrderedQueryable <T> GetOrderedDataModel(SearchPaginationRequest <T> request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            IQueryable <T> model = GetSearchedModel(request);

            IOrderedQueryable <T> orderedModel = null;

            if (string.IsNullOrEmpty(request.OrderBy))
            {
                request.OrderBy = "Id";

                orderedModel = model.OrderByPropertyName(
                    request.OrderBy,
                    request.IsOrderByAsc
                    );
            }
            else
            {
                orderedModel = model.OrderByJsonPropertyName(
                    request.OrderBy,
                    request.IsOrderByAsc
                    );
            }

            return(orderedModel);
        }
Пример #3
0
        public PaginationResponse <CategoryVM> GetDataWithPagination(PaginationRequest request)
        {
            SearchPaginationRequest <CategoryVM> nrequest = new SearchPaginationRequest <CategoryVM>(request);

            PaginationResponse <CategoryVM> data = CategoryRepository.GetDataPaginated(nrequest);

            return(data);
        }
        public PaginationResponse <TicketStatusVM> GetDataWithPagination(PaginationRequest request)
        {
            SearchPaginationRequest <TicketStatusVM> nrequest = new SearchPaginationRequest <TicketStatusVM>(request);

            PaginationResponse <TicketStatusVM> data = TicketStatusRepository.GetDataPaginated(nrequest);

            return(data);
        }
Пример #5
0
        public virtual IQueryable <T> GetSearchedModel(SearchPaginationRequest <T> request)
        {
            if (request != null)
            {
                return(GetSearchedModel(request.SearchData));
            }

            return(GetModel());
        }
Пример #6
0
 public PaginationResponse <Subscription> GetPageByStudent(long studentId, SearchPaginationRequest request)
 {
     using (var context = _sportEntitiesContextProvider.GetContext())
         return(GetPageWithSearch <Subscription>(context, request, _allIncludes,
                                                 new Expression <Func <Subscription, bool> >[]
         {
             x => x.StudentId == studentId
         }));
 }
Пример #7
0
        public PaginationResponse <TicketVM> SearchDataWithPagination([FromBody] SearchPaginationRequest <TicketVM> request)
        {
            string myUserId = User.FindFirst(ClaimTypes.Name)?.Value;

            if (request != null)
            {
                if (request.SearchData != null)
                {
                    request.SearchData.MyUserId = myUserId;
                }
            }

            return(TicketServices.SearchDataWithPagination(request));
        }
        public override IQueryable <CategoryVM> GetSearchedModel(SearchPaginationRequest <CategoryVM> request)
        {
            IQueryable <CategoryVM> model = GetModel();

            model = model.Where(u => u.IsDeleted != true);

            if (!string.IsNullOrEmpty(request?.SearchData?.Id))
            {
                model = model.Where(u => u.Id == request.SearchData.Id);
            }

            if (!string.IsNullOrEmpty(request?.SearchData?.Name))
            {
                model = model.Where(u => u.Name.Contains(request.SearchData.Name));
            }

            return(model);
        }
        public override IQueryable <TicketVM> GetSearchedModel(SearchPaginationRequest <TicketVM> request)
        {
            IQueryable <TicketVM> model = GetModel();

            string id       = request?.SearchData?.Id;
            string name     = request?.SearchData?.Name;
            string myuserid = request?.SearchData?.MyUserId;
            string statusID = request?.SearchData?.StatusID;

            model = model.Where(u => u.IsDeleted != true);

            if (!string.IsNullOrEmpty(id))
            {
                model = model.Where(u => u.Id == id);
            }

            if (!string.IsNullOrEmpty(name))
            {
                model = model.Where(u => u.Name.Contains(name));
            }

            if (!string.IsNullOrEmpty(statusID))
            {
                model = model.Where(u => u.StatusID == statusID);
            }

            if (
                !string.IsNullOrEmpty(request?.SearchData?.SeeType) &&
                !string.IsNullOrEmpty(request?.SearchData?.MyUserId)
                )
            {
                switch (request.SearchData.SeeType)
                {
                case "1": model = model.Where(u => u.OwnerID == myuserid); break;

                case "2": model = model.Where(u => u.AssigneeId == myuserid); break;
                }
            }

            return(model);
        }
Пример #10
0
        /**
         *  Mendapatkan Data Pada Page Tertentu
         **/
        public virtual PaginationResponse <T> GetDataPaginated(SearchPaginationRequest <T> request)
        {
            CommonResponse <T> response = ValidateParameter(request);

            if (response != null)
            {
                return(new PaginationResponse <T>
                {
                    Status = response.Status,
                    Code = response.Code,
                    Message = response.Message,
                });
            }

            IOrderedQueryable <T> model = GetOrderedDataModel(request);

            int totalData = model.Count();

            IEnumerable <T> selectedData = model.Skip(request.Offset)
                                           .Take(request.Size)
                                           .AsEnumerable();

            double totalPages = Math.Ceiling(
                totalData / ((double)Math.Max(request.Size, 1))
                );

            return(new PaginationResponse <T>
            {
                Status = true,
                Code = "S",
                Message = "Retrieve Data is Success!",
                TotalPages = (int)totalPages,
                PageSize = request.Size,
                CurrentPage = request.Page,
                Data = selectedData,
            });
        }
Пример #11
0
        internal PaginationResponse <TEntity> GetPageWithSearch <TTProperty>(DbContext context, SearchPaginationRequest request, Expression <Func <TEntity, object> >[] includes = null,
                                                                             Expression <Func <TEntity, bool> >[] where = null)
        {
            IQueryable <TEntity> pageEntities = context
                                                .Select(includes, where)
                                                .OrderBy(x => x.Id)
                                                .Skip(request.Skip)
                                                .Take(request.Limit);
            IQueryable <TEntity> allEntities = context.Set <TEntity>();

            return(new PaginationResponse <TEntity>
            {
                Items = pageEntities.ToArray(),
                TotalItemsCount = allEntities.Count(),
                Limit = request.Limit,
                CurrentPageIndex = request.PageIndex
            });
        }
Пример #12
0
 public PaginationResponse <TEntity> GetPage(SearchPaginationRequest request)
 {
     using (var context = _sportEntitiesContextProvider.GetContext())
         return(GetPageWithSearch <TEntity>(context, request, _allIncludes,
                                            string.IsNullOrWhiteSpace(request.SearchText) ? null : GetSearchExpression(request.SearchText)));
 }
 public PaginationResponse <StudentInSession> GetStudentsInSessionPage(long sessionId, SearchPaginationRequest request)
 {
     using (var context = _sportEntitiesContextProvider.GetContext())
         return(GetPageWithSearch <StudentInSession>(context, request,
                                                     new Expression <Func <StudentInSession, object> >[]
         {
             x => x.Student
         }, new Expression <Func <StudentInSession, bool> >[]
         {
             x => x.SessionId == sessionId
         }));
 }
Пример #14
0
 public PaginationResponse <CategoryVM> SearchDataWithPagination(SearchPaginationRequest <CategoryVM> request)
 {
     return(CategoryRepository.GetDataPaginated(request));
 }
Пример #15
0
 public PaginationResponse <UserVM> SearchDataWithPagination(SearchPaginationRequest <UserVM> request)
 {
     return(UserRepository.GetDataPaginated(request));
 }
 public PaginationResponse <TicketStatusVM> SearchDataWithPagination(SearchPaginationRequest <TicketStatusVM> request)
 {
     return(TicketStatusRepository.GetDataPaginated(request));
 }
 public PaginationResponse <UserVM> SearchDataWithPagination([FromBody] SearchPaginationRequest <UserVM> request)
 {
     return(UserServices.SearchDataWithPagination(request));
 }
 public PaginationResponse <CategoryVM> SearchDataWithPagination([FromBody] SearchPaginationRequest <CategoryVM> request)
 {
     return(CategoryServices.SearchDataWithPagination(request));
 }