public SumResultModel <ProductDto> CreateProduct(ProductDto entity)
        {
            SumResultModel <ProductDto> result = new SumResultModel <ProductDto>();

            Products product = new Products
            {
                ProductName     = entity.ProductName,
                CategoryId      = entity.CategoryId,
                SupplierId      = entity.SupplierId,
                QuantityPerUnit = entity.QuantityPerUnit,
                Discontinued    = entity.Discontinued,
                UnitPrice       = entity.UnitPrice,
                ReorderLevel    = entity.ReorderLevel,
                UnitsInStock    = entity.UnitsInStock,
                UnitsOnOrder    = entity.UnitsOnOrder
            };

            var item = _repository.Create(product);

            if (item != null)
            {
                result.SingleData      = ProductById(item.ProductId);
                result.Success         = true;
                result.StatusCode      = 200;
                result.ReadableMessage = "Process is successfully";
            }
            else
            {
                result.Success         = false;
                result.StatusCode      = 500;
                result.ReadableMessage = "Something went wrong";
            }

            return(result);
        }
        public SumResultModel <ProductDto> GetProductById(int id)
        {
            SumResultModel <ProductDto> result = new SumResultModel <ProductDto>();

            var product = ProductById(id);

            if (product != null)
            {
                result.SingleData = product;
                result.Success    = true;
                result.StatusCode = 200;
            }
            else
            {
                result.Success         = false;
                result.ReadableMessage = "Product is not found";
                result.StatusCode      = 204;
            }

            return(result);
        }
        public SumResultModel <bool> DeleteProduct(int id)
        {
            SumResultModel <bool> result = new SumResultModel <bool>();
            var product = _repository.GetById(id);

            if (product != null)
            {
                result.SingleData      = true;
                result.Success         = true;
                result.StatusCode      = 200;
                result.ReadableMessage = "Process is successfully";
            }
            else
            {
                result.Success         = false;
                result.ReadableMessage = "Product is not found";
                result.StatusCode      = 204;
            }

            return(result);
        }
        public SumResultModel <ProductListDto> GetProductList(Expression <Func <Products, bool> > filter = null, DataPagingOptions dataPagingOptions = null)
        {
            SumResultModel <ProductListDto> result = new SumResultModel <ProductListDto>();

            var list = _repository.Get(filter, dataPagingOptions).Select(c => new ProductListDto
            {
                ProductId       = c.ProductId,
                CategoryName    = c.CategoryId != null ? _baseCrudCategoryRepository.GetById((int)c.CategoryId).CategoryName : string.Empty,
                ProductName     = c.ProductName,
                QuantityPerUnit = c.QuantityPerUnit,
                SupplierName    = c.SupplierId != null ? _baseCrudSupplierRepository.GetById((int)c.SupplierId).CompanyName : string.Empty,
                UnitPrice       = c.UnitPrice,
                UnitsInStock    = c.UnitsInStock
            }).ToList();

            result.Data             = list;
            result.Success          = true;
            result.StatusCode       = 200;
            result.TotalRecordCount = _repository.GetTotalRecordCount();

            return(result);
        }