public IEnumerable<Product> GetAllProduct()
        {
            var records = db.products.ToList();
            foreach (var r in records)
            {
                Product p = new Product() {
                    ProductId = r.ProductId,
                    productNameCN = r.productNameCN,
                    ID =  r.ID,
                    weight = r.weight,
                    retailPrice = r.retailPrice,
                    barcode = r.barcode,
                    type = r.type,
                    cost = r.cost,
                    productName=r.productName
                };
                productList.Add(p);
            }

            return productList;
        }
        public IEnumerable<Product> GetAllProduct(int startIndex, int pageSize, string sortBy)
        {
            var records = new List<product>();
            switch (sortBy)
            {
                case null:
                    records = db.products.OrderBy(x => x.ID).ToList();
                    break;
                case "retailPrice ASC":
                    records = db.products.OrderBy(x => x.retailPrice).ToList();
                    break;
                case "retailPrice DESC":
                    records = db.products.OrderByDescending(x => x.retailPrice).ToList();
                    break;
                case "productNameCN ASC":
                    records = db.products.OrderBy(x => x.productNameCN).ToList();
                    break;
                case "productNameCN DESC":
                    records = db.products.OrderByDescending(x => x.productNameCN).ToList();
                    break;
                   case "ID ASC":
                    records = db.products.OrderBy(x => x.ID).ToList();
                    break;
                case "ID DESC":
                    records = db.products.OrderByDescending(x => x.ID).ToList();
                    break;
                case "type ASC":
                    records = db.products.OrderBy(x => x.type).ToList();
                    break;
                case "type DESC":
                     records = db.products.OrderByDescending(x => x.type).ToList();
                    break;
                default:
                    throw new Exception();

            }
              foreach (var r in records)
            {
                Product p = new Product() {
                    ProductId = r.ProductId,
                    productNameCN = r.productNameCN,
                    ID =  r.ID,
                    weight = r.weight,
                    retailPrice = r.retailPrice,
                    barcode = r.barcode,
                    type = r.type,
                    cost = r.cost,
                    productName=r.productName
                };
                productList.Add(p);
            }
              return productList;
        }