[HttpPost]//posting to the view public ActionResult DeleteProduct(ProductModel products) { try { var productMap = AutoMapper.Mapper.Map <ProductModel, Product>(products); productDetails.DeleteProduct(productMap); return(RedirectToAction("ViewProduct")); } catch { return(RedirectToAction("Error", "Error")); } }
// GET: ProductController/Delete/5 public ActionResult Delete(int id) { try { _productBL.DeleteProduct(_productBL.GetProductById(id)); Log.Information($"Product deleted-- ID: {id}"); return(RedirectToAction(nameof(Index))); } catch (Exception e) { Helper.WriteError(e, "Error"); Helper.WriteFatal(e, "Fatal"); Helper.WriteVerbose(e, "Verbose"); return(View()); } }
public void Delete(int id) { productBL.DeleteProduct(id); }