public ProductSearchResponse GetAllProducts() { List<Product> products = new List<Product>(); productDataManager = new ProductDataManager(); DataSet ds = productDataManager.GetAllProducts(); ProductSearchResponse response = new ProductSearchResponse(); DataTable dt = new DataTable(); dt = ds.Tables[0]; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Product product = new Product(); product.Id = Convert.ToInt32(dr["Id"]); product.Name = dr["Name"].ToString(); product.Description = dr["Description"].ToString(); product.Price = Convert.ToDecimal(dr["Price"]); product.Status = dr["Status"].ToString(); product.Category = new Category(); product.Category.CategoryName = Convert.ToString(dr["CategoryName"]); if (dr["CategoryId"] != System.DBNull.Value) { product.Category.CategoryId = Convert.ToInt32(dr["CategoryId"]); } products.Add(product); } } // NoOfRows = dt.Rows.Count; response.ProductList = products; response.Count = Convert.ToInt32(ds.Tables[1].Rows[0][0]); return response; }
//private static List<Product> _products; //[HttpPost] public void PostProduct(Product product) { // Product product = new Product(); //if (_products == null) //{ // _products = new List<Product>(); //} IProductManager productManager = ProductFactory.GetProductManager(); product.Id = productManager.InsertProduct(product); }
private void UpdateProducts(Product product) { IProductManager productManager = ProductFactory.GetProductManager(); int result = productManager.UpdateProducts(product); Response.Clear(); if (result > 0) { Response.Write("Successfully Updated"); } else { Response.Write("Error while updating"); } Response.End(); }
//protected void btnSubmit_Click(object sender, EventArgs e) //{ // Product product = new Product(); // IProductManager productManager = ProductFactory.GetProductManager(); // product.Name = Convert.ToString(txtName.Text); // product.Description = Convert.ToString(txtDesc.Text); // product.Price = Convert.ToDecimal(txtPrice.Text); // product.Status = Convert.ToString(ddlStatus.SelectedValue); // int result = productManager.InsertProduct(product); // if (result > 0) // { // lblMsg.Text = "Success"; // } // else // { // lblMsg.Text = "No success"; // } //} //private void SaveProduct(string Name, string Description, string Price, string Status) private void SaveProduct(Product product) { IProductManager productManager = ProductFactory.GetProductManager(); //Product product = new Product(); //product.Name = Convert.ToString(Name); //product.Description = Convert.ToString(Description); //product.Price = Convert.ToDecimal(Price); //product.Status = Convert.ToString(Status); //int result = productManager.InsertProduct(product); int result = productManager.InsertProduct(product); Response.Clear(); //Response.ContentType = "application/json"; if (result > 0) { Response.Write("Successfully Inserted"); } else { Response.Write("Error while inserting data"); } Response.End(); }
public void PutProduct(Product product) { IProductManager productManager = ProductFactory.GetProductManager(); productManager.UpdateProducts(product); }
public int UpdateProducts(Product product) { productDataManager = new ProductDataManager(); return productDataManager.UpdateProducts(product.Id,product.Name, product.Description, product.Price, product.Status,product.Category.CategoryId); }
public int InsertProduct(Product product) { productDataManager = new ProductDataManager(); return productDataManager.InsertProduct(product.Name, product.Description, product.Price, product.Status, product.Category.CategoryId); }
public int InsertProduct(Product product) { throw new NotImplementedException(); }