コード例 #1
0
        public async Task <PageListUtility <Employee> > GetAllEmployee(SortParams[] sortParams, PaginationParams paginationParams, string filter)
        {
            var data = _employeeRepository.FindAll();

            if (!string.IsNullOrEmpty(filter))
            {
                data = data.Where(x => x.Name.Contains(filter));
            }
            var orderedData = data.OrderBy(x => 0);

            foreach (var sort in sortParams)
            {
                switch (sort.sortBy)
                {
                case nameof(Employee.Name):
                    orderedData = sort.sortType == SortBy.Asc ? orderedData.ThenBy(x => x.Name) : orderedData.ThenByDescending(x => x.Name);
                    break;

                case nameof(Employee.Address):
                    orderedData = sort.sortType == SortBy.Asc ? orderedData.ThenBy(x => x.Address) : orderedData.ThenByDescending(x => x.Address);
                    break;

                default:
                    break;
                }
            }

            return(await PageListUtility <Employee> .PageListAsync(orderedData, paginationParams.PageNumber, paginationParams.PageSize));
        }
コード例 #2
0
        public async Task <PageListUtility <Article_Dto> > SearchArticleWithPaginations(PaginationParams param, string articleCateID, string articleName)
        {
            var articleCateList = _articleCategoryRepository.FindAll();
            var articleList     = _articleRepository.FindAll();

            if (!string.IsNullOrEmpty(articleCateID))
            {
                articleCateList = articleCateList.Where(x => x.Article_Cate_ID == articleCateID);
            }
            if (!string.IsNullOrEmpty(articleName))
            {
                articleList = articleList.Where(x => x.Article_Name == articleName);
            }

            var query = articleCateList.Join(
                articleList,
                x => x.Article_Cate_ID,
                y => y.Article_Cate_ID,
                (x, y) => new Article_Dto
            {
                Article_Cate_ID = y.Article_Cate_ID,
                Alias           = y.Alias,
                Article_ID      = y.Article_ID,
                Article_Name    = y.Article_Name,
                Content         = y.Content,
                Files           = y.Files,
                Link            = y.Link,
                Status          = y.Status,
                Update_By       = y.Update_By,
                Update_Time     = y.Update_Time
            }).OrderByDescending(x => x.Article_Cate_ID).ThenBy(x => x.Article_ID);

            return(await PageListUtility <Article_Dto> .PageListAsync(query, param.PageNumber, param.PageSize));
        }
コード例 #3
0
ファイル: UserService.cs プロジェクト: nhokasa/Dropzone_V2
        public async Task <PageListUtility <User_Detail_Dto> > Search(PaginationParams param, string text)
        {
            var usersQuery = _userRepository
                             .FindAll(x => x.Factory_ID.ToLower().Contains(text.ToLower()) || x.User_Account.ToLower().Contains(text.ToLower()) || x.User_Name.ToLower().Contains(text.ToLower()) || x.Email.ToLower().Contains(text.ToLower()))
                             .OrderByDescending(x => x.Update_Time)
                             .ProjectTo <User_Detail_Dto>(_mapperConfiguration);

            return(await PageListUtility <User_Detail_Dto> .PageListAsync(usersQuery, param.PageNumber, param.PageSize));
        }
コード例 #4
0
ファイル: UserService.cs プロジェクト: nhokasa/Dropzone_V2
        public async Task <PageListUtility <User_Detail_Dto> > GetUserWithPaginations(PaginationParams param)
        {
            var usersQuery = _userRepository
                             .FindAll()
                             .OrderByDescending(x => x.Update_Time)
                             .ProjectTo <User_Detail_Dto>(_mapperConfiguration);

            return(await PageListUtility <User_Detail_Dto> .PageListAsync(usersQuery, param.PageNumber, param.PageSize));
        }
コード例 #5
0
        public override async Task <PageListUtility <PDCDto> > Search(string keyword, PaginationParams parms)
        {
            var query = _repo.FindAll();

            if (!String.IsNullOrEmpty(keyword))
            {
                query = query.Where(x => x.PDCName.Contains(keyword) || x.PDCCode.Contains(keyword));
            }

            return(await PageListUtility <PDCDto> .PageListAsync(query.AsNoTracking().ProjectTo <PDCDto>(_configuration), parms.PageNumber, parms.PageSize));
        }
コード例 #6
0
        public async Task <PageListUtility <ProductCategory_Dto> > GetProductCategoryWithPaginations(PaginationParams param, string text)
        {
            var data = _productCategoryRepository.FindAll().ProjectTo <ProductCategory_Dto>(_configuration).OrderByDescending(x => x.Update_Time);

            if (text != null)
            {
                data = data.Where(x => x.Product_Cate_Name.ToLower().Contains(text.ToLower()) ||
                                  x.Update_By.ToLower().Contains(text.ToLower()) ||
                                  x.Product_Cate_ID.ToLower().Contains(text.ToLower())).OrderByDescending(x => x.Update_Time);
            }
            return(await PageListUtility <ProductCategory_Dto> .PageListAsync(data, param.PageNumber, param.PageSize));
        }
コード例 #7
0
ファイル: UserService.cs プロジェクト: HuynhEmCuong/ProjectEx
        public override async Task <PageListUtility <UserDto> > Search(string keyword, PaginationParams parms)
        {
            var queryData = _repo.FindAll();

            if (!String.IsNullOrEmpty(keyword))
            {
                queryData = queryData.Where(x => x.UserName.Contains(keyword.ToString()) ||
                                            x.EmpName.Contains(keyword.ToString()) ||
                                            x.UpdateBy.Contains(keyword.ToString()));
            }
            return(await PageListUtility <UserDto> .PageListAsync(queryData.AsNoTracking().ProjectTo <UserDto>(_configuration).OrderByDescending(x => x.UpdateDate), parms.PageNumber, parms.PageSize));
        }
コード例 #8
0
        public async Task <PageListUtility <ArticleCategory_Dto> > GetArticleCategoryWithPaginations(PaginationParams param, string text, bool isPaging = true)
        {
            var data = _articleCategoryRepository.FindAll().ProjectTo <ArticleCategory_Dto>(_configuration).OrderByDescending(x => x.Update_Time);

            if (!string.IsNullOrEmpty(text))
            {
                data = data.Where(x => x.Article_Cate_Name.ToLower().Contains(text.ToLower()) ||
                                  x.Update_By.ToLower().Contains(text.ToLower()) ||
                                  x.Article_Cate_ID.ToLower().Contains(text.ToLower())).OrderByDescending(x => x.Update_Time);
            }
            return(await PageListUtility <ArticleCategory_Dto> .PageListAsync(data, param.PageNumber, param.PageSize, isPaging));
        }
コード例 #9
0
ファイル: ProductService.cs プロジェクト: nhokasa/Dropzone_V2
        public async Task <PageListUtility <Product_Dto> > GetProductWithPaginations(PaginationParams param, string text)
        {
            var data = _productRepository.FindAll().ProjectTo <Product_Dto>(_configuration).OrderByDescending(x => x.Product_Cate_ID).ThenBy(x => x.Product_ID);

            if (!string.IsNullOrEmpty(text))
            {
                data = data.Where(x => x.Product_ID.ToString().ToLower().Contains(text.ToLower()) ||
                                  x.Product_Name.ToLower().Contains(text.ToLower()) ||
                                  x.Update_By.ToLower().Contains(text.ToLower()) ||
                                  x.Product_Cate_ID.ToLower().Contains(text.ToLower())
                                  ).OrderByDescending(x => x.Product_Cate_ID).ThenBy(x => x.Product_ID);
            }
            return(await PageListUtility <Product_Dto> .PageListAsync(data, param.PageNumber, param.PageSize));
        }
コード例 #10
0
        public async Task <PageListUtility <Product_Dto> > SearchProductWithPaginations(PaginationParams param, string productCateID, string productName, bool isPaging = true)
        {
            var productCateList = _productCategoryRepository.FindAll();
            var productList     = _productRepository.FindAll();

            if (!string.IsNullOrEmpty(productCateID))
            {
                productCateList = productCateList.Where(x => x.Product_Cate_ID == productCateID);
            }
            if (!string.IsNullOrEmpty(productName))
            {
                productList = productList.Where(x => x.Product_Name == productName);
            }

            var query = productCateList.Join(
                productList,
                x => x.Product_Cate_ID,
                y => y.Product_Cate_ID,
                (x, y) => new Product_Dto {
                Amount          = y.Amount,
                Content         = y.Content,
                Discount        = y.Discount,
                From_Date_Sale  = y.From_Date_Sale,
                Hot_Sale        = y.Hot_Sale,
                IsSale          = y.IsSale,
                New             = y.New,
                Price           = y.Price,
                Price_Sale      = y.Price_Sale,
                Product_Cate_ID = y.Product_Cate_ID,
                Product_ID      = y.Product_ID,
                Product_Name    = y.Product_Name,
                Status          = y.Status,
                Time_Sale       = y.Time_Sale,
                To_Date_Sale    = y.To_Date_Sale,
                Update_By       = y.Update_By,
                Update_Time     = y.Update_Time,
                FileImages      = y.FileImages,
                FileVideos      = y.FileVideos
            }).OrderByDescending(x => x.Update_Time);

            return(await PageListUtility <Product_Dto> .PageListAsync(query, param.PageNumber, param.PageSize, isPaging));
        }