Exemple #1
0
        public async Task <ApiResponseResult> GetAllProducts(int?pageNumber = 1, int?pageSize = 10)
        {
            ApiResponseResult            apiResponseResult = new ApiResponseResult();
            paginationDTO <ProductModel> paginatedorders   = new paginationDTO <ProductModel>();

            try
            {
                var model = _productRepository.GetProducts(pageNumber, pageSize);
                paginatedorders.Paging = model.GetHeader();
                //paginatedorders.pagedLinks = _categoryRepository.pageLinks(routname, pageNumber.Value, pageSize.Value, paginatedorders.Paging.TotalItems);
                paginatedorders.Items = await model.List;

                apiResponseResult.data = paginatedorders;

                //apiResponseResult.data          = _productRepository.GetProducts(pageNumber, pageSize);
                apiResponseResult.message   = "Products Get Successfully";
                apiResponseResult.ErrorCode = (int)Constant.Error.NO_ERROR;
                apiResponseResult.status    = true;
            }
            catch (Exception exc)
            {
                apiResponseResult.message   = exc.Message;
                apiResponseResult.ErrorCode = (int)Constant.Error.EXCEPTION;
                apiResponseResult.status    = false;
            }
            return(apiResponseResult);
        }
Exemple #2
0
        public async Task <ApiResponseResult> SearchProduct(string search, int?categoryId = 0, int?pageNumber = 1, int?pageSize = 10)
        {
            ApiResponseResult            apiResponseResult = new ApiResponseResult();
            paginationDTO <ProductModel> paginatedorders   = new paginationDTO <ProductModel>();

            try
            {
                if (search == "" || search == null)
                {
                    apiResponseResult.message   = "Search empty string";
                    apiResponseResult.ErrorCode = (int)Constant.Error.ENTITY_EXCEPTION;
                    apiResponseResult.status    = false;
                    return(apiResponseResult);
                }


                var model = _productRepository.SearchProduct(search, categoryId, pageNumber, pageSize);
                paginatedorders.Paging = model.GetHeader();
                //paginatedorders.pagedLinks = _categoryRepository.pageLinks(routname, pageNumber.Value, pageSize.Value, paginatedorders.Paging.TotalItems);
                paginatedorders.Items = await model.List;

                if (paginatedorders.Items.Count == 0)
                {
                    apiResponseResult.message   = "No product found";
                    apiResponseResult.ErrorCode = (int)Constant.Error.RECIEVE_DATA_NULL;
                    apiResponseResult.status    = false;
                    return(apiResponseResult);
                }

                apiResponseResult.data = paginatedorders;

                //apiResponseResult.data          = _productRepository.GetProducts(pageNumber, pageSize);
                apiResponseResult.message   = "Products Get Successfully";
                apiResponseResult.ErrorCode = (int)Constant.Error.NO_ERROR;
                apiResponseResult.status    = true;
            }
            catch (Exception exc)
            {
                apiResponseResult.message   = exc.Message;
                apiResponseResult.ErrorCode = (int)Constant.Error.EXCEPTION;
                apiResponseResult.status    = false;
            }
            return(apiResponseResult);
        }
        public async Task <ApiResponseResult> GetOrders(int?userId = 0, int?pageNumber = 1, int?pageSize = 10)
        {
            ApiResponseResult        apiResponseResult = new ApiResponseResult();
            paginationDTO <OrderDTO> paginatedorders   = new paginationDTO <OrderDTO>();

            try
            {
                var model = orderRepository.GetOrders(userId, pageNumber, pageSize);
                paginatedorders.Paging      = model.GetHeader();
                paginatedorders.Items       = await model.List;
                apiResponseResult.data      = paginatedorders;
                apiResponseResult.message   = "Orders Get Successfully !";
                apiResponseResult.ErrorCode = (int)Constant.Error.NO_ERROR;
                apiResponseResult.status    = true;
            }
            catch (Exception exc)
            {
                apiResponseResult.message   = exc.Message;
                apiResponseResult.ErrorCode = (int)Constant.Error.EXCEPTION;
                apiResponseResult.status    = false;
            }
            return(apiResponseResult);
        }