public IHttpActionResult Putproduct_table(int id, product_table product_table) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product_table.productId) { return(BadRequest()); } db.Entry(product_table).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!product_tableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { product_table product_table = db.product_tables.Find(id); db.product_tables.Remove(product_table); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Pro_id,Pro_details,Pro_price,Pro_qty,Pro_name,Cat_Id")] product_table product_table) { if (ModelState.IsValid) { db.Entry(product_table).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Cat_Id = new SelectList(db.categories_tables, "Cat_id", "Cat_name", product_table.Cat_Id); return(View(product_table)); }
public IHttpActionResult Getproduct_table(int id) { product_table product_table = db.product_table.Find(id); if (product_table == null) { return(NotFound()); } return(Ok(product_table)); }
public ActionResult Edit([Bind(Include = "product_id,product_name,product_price,product_quantity,product_details,cat_id")] product_table product_table) { if (ModelState.IsValid) { db.Entry(product_table).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.cat_id = new SelectList(db.category_tables, "cat_id", "cat_name", product_table.cat_id); return(View(product_table)); }
public IHttpActionResult Postproduct_table(product_table product_table) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.product_table.Add(product_table); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = product_table.productId }, product_table)); }
// GET: product/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } product_table product_table = db.product_tables.Find(id); if (product_table == null) { return(HttpNotFound()); } return(View(product_table)); }
public IHttpActionResult Deleteproduct_table(int id) { product_table product_table = db.product_table.Find(id); if (product_table == null) { return(NotFound()); } db.product_table.Remove(product_table); db.SaveChanges(); return(Ok(product_table)); }
// GET: product/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } product_table product_table = db.product_tables.Find(id); if (product_table == null) { return(HttpNotFound()); } ViewBag.Cat_Id = new SelectList(db.categories_tables, "Cat_id", "Cat_name", product_table.Cat_Id); return(View(product_table)); }
private void AddProducts() { CricketSystemEntities context = new CricketSystemEntities(); product_table tbl = new product_table(); string fileName = System.IO.Path.GetFileName(FileUploadAdd.FileName); if (txtProductname.Text == "") { lblRegisterError.Text = "Please provide Product name."; } else if (ddlType.SelectedIndex == 0) { lblRegisterError.Text = "Please select product type."; } else if (txtProductPrice.Text == "") { lblRegisterError.Text = "Please provide Product price."; } else if (txtProductNo.Text == "") { lblRegisterError.Text = "Please provide No of Products available in stock."; } else if (!Regex.Match(txtProductPrice.Text, "^\\$?(\\d{1,3},(\\d{3},)*\\d{3}|\\d+)(.\\d{1,4})?$").Success) { lblRegisterError.Text = "Invalid Product price."; } else if (FileUploadAdd.FileName == "") { lblRegisterError.Text = "Please select product Image."; } else { //Set the Image File Path. string filePath = "~/Pictures/Products/" + fileName; int userId = Convert.ToInt32(lblUsername.Text); //Save the Image File in Folder. FileUploadAdd.SaveAs(Server.MapPath(filePath)); tbl.Name = UpperCaseFirst(txtProductname.Text); tbl.product_purpose = "Sell"; tbl.Product_type = ddlType.SelectedValue; tbl.Price = txtProductPrice.Text; tbl.ProductNo = Convert.ToInt32(txtProductNo.Text); tbl.Image_url = filePath; tbl.Username = GetUsername(userId); tbl.User_id = userId; tbl.UserType = "Supplier"; context.product_table.Add(tbl); context.SaveChanges(); lblRegisterError.Text = "Product Added."; lblRegisterError.ForeColor = Color.MidnightBlue; TextBox[] txt = { txtProductname, txtProductPrice, txtProductNo }; for (int i = 0; i < txt.Length; i++) { txt[i].Text = ""; } ddlType.SelectedIndex = 0; } }