Exemple #1
0
        //所有產品
        public IEnumerable <ProductsItem> GetAllproduct(int Id, ForPaging Paging)
        {
            var result = productsRepository.GetAll().Where((x) => x.CategoryID == Id);

            Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(result.Count()) / Paging.ItemNum));
            Paging.SetRightPage();
            return(result.OrderBy(x => x.ProductID).Skip((Paging.NowPage - 1) * Paging.ItemNum).Take(Paging.ItemNum));
        }
Exemple #2
0
        // 搜尋產品
        public IEnumerable <ProductsItem> GetSearchProductName(string Search, ForPaging Paging)
        {
            IEnumerable <ProductsItem> Data;

            if (String.IsNullOrEmpty(Search))
            {
                Data           = productsRepository.GetAll();
                Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
                Paging.SetRightPage();
            }
            else
            {
                Data           = productsRepository.SearchByProductName(Search);
                Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
                Paging.SetRightPage();
            }
            return(Data.OrderBy(x => x.ProductID).Skip((Paging.NowPage - 1) * Paging.ItemNum).Take(Paging.ItemNum));
        }
        public IEnumerable <Customers> CustomerList(string Search, ForPaging Paging)
        {
            IEnumerable <Customers> Data;

            if (String.IsNullOrEmpty(Search))
            {
                Data           = repository.GetAll();
                Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
                Paging.SetRightPage();
            }
            else
            {
                Data           = repository.SearchById(Search);
                Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
                Paging.SetRightPage();
            }
            return(Data.OrderBy(x => x.CustomerID).Skip((Paging.NowPage - 1) * Paging.ItemNum).Take(Paging.ItemNum));
        }
        //訂單列表 帶狀態
        public IEnumerable <AdminOrder> GetOrderList(string Search, ForPaging Paging, int status)
        {
            IEnumerable <AdminOrder> Data;

            if (String.IsNullOrEmpty(Search))
            {
                Data = ordersRepository.GetAll_Admin().Where(x => x.Status == status);
            }
            else
            {
                Data = ordersRepository.SearchById_Admin(Search).Where(x => x.Status == status);
            }

            Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
            Paging.SetRightPage();

            return(Data.OrderByDescending(x => x.OrderDate).Skip((Paging.NowPage - 1) * Paging.ItemNum).Take(Paging.ItemNum));
        }
        public IEnumerable <CustomerOrder> GetCustomerOrderList(string customerId, string orderId, ForPaging Paging)
        {
            IEnumerable <CustomerOrder> Data;

            if (String.IsNullOrEmpty(orderId))
            {
                Data = ordersRepository.GetAll_Customer(customerId);
            }
            else
            {
                Data = ordersRepository.SearchById_Customer(customerId, orderId);
            }

            Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
            Paging.SetRightPage();

            return(Data.OrderByDescending(x => x.OrderDate).Skip((Paging.NowPage - 1) * Paging.ItemNum).Take(Paging.ItemNum));
        }