public ActionResult Delete(int ID) { if (Session["role"] == null || (int)Session["role"] < Editor) { return(Redirect("/CMS/Product")); } ProductsTable produkt = pf.Get(ID); if (produkt.Image != null) { string imagePath = Request.PhysicalApplicationPath + "/Images/Products/" + produkt.Image; if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } pf.Delete(ID); return(Redirect("/CMS/Product")); }
protected void dgProductList_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandArgument.ToString() == "DeleteInfo") { int dataKey = Convert.ToInt32(this.dgProductList.DataKeys[e.Item.ItemIndex]); ProductFactory.Delete(dataKey); this.LoadListData(); } }
public ActionResult DeleteProduct(int id) { productFactory.Delete(id); foreach (Image img in imageFactory.GetBy("ProductID", id)) { img.ProductID = 0; imageFactory.Update(img); } TempData["MSG"] = "A product with ID: " + id + " has been deleted."; return(RedirectToAction("Products")); }
public ActionResult DeletePopup(string ID, string PinCode, string Reason) { try { if (!PinCode.Equals(CurrentUser.PinCode)) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } string msg = ""; var result = _factory.Delete(ID, CurrentUser.UserId, ref msg, Reason); if (!result) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); } catch (Exception ex) { NSLog.Logger.Error("Products Delete: ", ex); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
protected void btnBatchDelete_Click(object sender, EventArgs e) { List <int> ids = new List <int>(); DataGridItemCollection items = this.dgProductList.Items; foreach (DataGridItem item in items) { CheckBox chkIsSelect = item.FindControl("chkIsSelect") as CheckBox; if (chkIsSelect != null && chkIsSelect.Checked) { ids.Add(Convert.ToInt32(this.dgProductList.DataKeys[item.ItemIndex])); } } foreach (int id in ids) { ProductFactory.Delete(id); } this.LoadListData(); }