Ejemplo n.º 1
0
        public ApiListResult <ProductAttributeMappingDTO> Get([FromUri] AntPageOption option = null)
        {
            var query = ProductAttributeMappingService
                        .GetAll()
                        .Include(x => x.ProductAttributeValues)
                        .ProjectTo <ProductAttributeMappingDTO>();

            if (option != null)
            {
                if (!string.IsNullOrEmpty(option.SortField))
                {
                    //for example
                    if (option.SortField == "id")
                    {
                        if (option.SortOrder == PageSortTyoe.DESC)
                        {
                            query = query.OrderByDescending(x => x.Id);
                        }
                        else
                        {
                            query = query.OrderBy(x => x.Id);
                        }
                    }
                }

                if (option.Page > 0 && option.Results > 0)
                {
                    if (string.IsNullOrEmpty(option.SortField))
                    {
                        query = query.OrderBy(x => x.Id);
                    }
                }
            }
            else
            {
                query = query.OrderBy(x => x.Id);
            }
            var count  = query.Count();
            var result = query.Paging <ProductAttributeMappingDTO>(option.Page - 1, option.Results, count);

            return(new ApiListResult <ProductAttributeMappingDTO>(result, result.PageIndex, result.PageSize, count));
        }
Ejemplo n.º 2
0
        public ApiListResult <DepartmentDTO> Get([FromUri] AntPageOption option = null)
        {
            var query = DepartmentService.GetAll().Where(x => !x.Deleted).ProjectTo <DepartmentDTO>();

            if (option != null)
            {
                if (!string.IsNullOrEmpty(option.SortField))
                {
                    //for example
                    if (option.SortField == "code")
                    {
                        if (option.SortOrder == PageSortTyoe.DESC)
                        {
                            query = query.OrderByDescending(x => x.Code);
                        }
                        else
                        {
                            query = query.OrderBy(x => x.Code);
                        }
                    }
                }

                if (option.Page > 0 && option.Results > 0)
                {
                    if (string.IsNullOrEmpty(option.SortField))
                    {
                        query = query.OrderBy(x => x.Code);
                    }
                }
            }
            else
            {
                query = query.OrderBy(x => x.Code);
            }
            var count  = query.Count();
            var result = query.Paging <DepartmentDTO>(option.Page - 1, option.Results, count);

            return(new ApiListResult <DepartmentDTO>(result, result.PageIndex, result.PageSize, count));
        }
Ejemplo n.º 3
0
        public ApiListResult <MemberDTO> Get([FromUri] AntPageOption option = null)
        {
            var query = UserManager.Users.Where(x => !x.Deleted).ProjectTo <MemberDTO>();

            if (option != null)
            {
                if (!string.IsNullOrEmpty(option.SortField))
                {
                    //for example
                    if (option.SortField == "id")
                    {
                        if (option.SortOrder == PageSortTyoe.DESC)
                        {
                            query = query.OrderByDescending(x => x.Id);
                        }
                        else
                        {
                            query = query.OrderBy(x => x.Id);
                        }
                    }
                }

                if (option.Page > 0 && option.Results > 0)
                {
                    if (string.IsNullOrEmpty(option.SortField))
                    {
                        query = query.OrderBy(x => x.Id);
                    }
                }
            }
            else
            {
                query = query.OrderBy(x => x.Id);
            }
            var count  = query.Count();
            var result = query.Paging <MemberDTO>(option.Page - 1, option.Results, count);

            return(new ApiListResult <MemberDTO>(result, result.PageIndex, result.PageSize, count));
        }