public ActionResult DeleteConfirm(int id)
        {
            bool result = ProductRepo.Delete(id);

            UserViewModel modul = CompanyRepo.GetIdByName(User.Identity.Name);

            if (modul.Role == "Admin")
            {
                if (CompanyRepo.Delete(id))
                {
                    return(Json(new
                    {
                        success = result,
                        entity = "",
                        message = "delete success"
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        success = result,
                        entity = "",
                        message = "delete fail"
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" })));
            }
        }
Exemple #2
0
 public ActionResult DeleteConfirm(int id)
 {
     if (ProductRepo.Delete(id))
     {
         return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult Delete(ProductViewModel model)
        {
            ResponResultViewModel result = ProductRepo.Delete(model.id);

            return(Json(new
            {
                success = result.Success,
                message = result.Message,
                entity = result.Entity
            }, JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        public void OnGet(int id)
        {
            var  productRepo = new ProductRepo();
            bool success     = productRepo.Delete(id);

            if (success)
            {
                ViewData["DeleteProduct"] = "Delete product successfully.";
            }
            else
            {
                ViewData["DeleteProduct"] = $"Error! There's no product with ID = {id}.";
            }
        }
Exemple #5
0
        public ActionResult ConfirmDelete(string Id)
        {
            Product productToDelete = Cotext.Find(Id);

            if (productToDelete == null)
            {
                return(HttpNotFound());
            }
            else
            {
                Cotext.Delete(Id);
                Cotext.Commit();
                return(RedirectToAction("Index"));
            }
        }
 public ActionResult Delete(VMProduct paramModel)
 {
     try
     {
         return(Json(new
         {
             success = ProductRepo.Delete(paramModel),
             message = ProductRepo.Message
         }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception hasError)
     {
         return(Json(new { success = false, message = hasError.Message },
                     JsonRequestBehavior.AllowGet));
     }
 }
Exemple #7
0
        private void silToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (_selectedCat != null)
                {
                    if (_selectedCat is CategoryViewModel selected)
                    {
                        using (var categoryRepo = new CategoryRepo())
                        {
                            var cat = categoryRepo.GetById(selected.Id);
                            if (cat.Products.Count == 0)
                            {
                                categoryRepo.Delete(cat);
                                MessageBox.Show($"Secilen {cat.CategoryName} isimli kategori basariyla silindi");
                            }
                            else
                            {
                                throw new Exception($"{cat.CategoryName} kategorisi, urun bulundurduğundan dolayı silinemez");
                            }
                        }
                    }
                }

                if (_selectedProduct != null)
                {
                    _selectedCat = null;
                    if (_selectedProduct is ProductViewModel selected)
                    {
                        using (var productRepo = new ProductRepo())
                        {
                            var product = productRepo.GetById(selected.Id);
                            productRepo.Delete(product);
                            MessageBox.Show($"Secilen {product.ProductName} isimli ürün basariyla silindi");
                        }
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                new EntityHelper().FindError(ex);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 //[ValidateAntiForgeryToken]
 public async Task <ActionResult> Delete(ProductViewModel product)
 {
     try
     {
         _productRepo.Delete(Mapper.Map <ProductViewModel, Product>(product));
         LogProductCRUD(product, Actions.Delete);
         return(RedirectToAction("Index"));
     }
     catch (DbUpdateConcurrencyException)
     {
         ModelState.AddModelError(string.Empty, "Unable to delete record. Another user updated the record.");
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, $"Unable to create record: {ex.Message}");
     }
     return(View(product));
 }
Exemple #9
0
        private void btdelete_Click(object sender, EventArgs e)
        {
            if (gvproducts.SelectedRows.Count == 0)
            {
                MessageBox.Show("Tidak ada barang yang akan dihapus");
            }
            else
            {
                //var id = Convert.ToInt32(gvproducts.Rows[gvproducts.CurrentCell.RowIndex].Cells["id"].Value);
                var selectedRowId     = (int)gvproducts.SelectedRows[0].Cells["id"].Value;
                var selectedSalePrice = salePriceRepo.GetById(selectedRowId);

                if (selectedSalePrice == null)
                {
                    var form = new ConfirmationDialog();
                    form.Message = "Apa anda yakin menghapus barang terpilih?";
                    form.ShowDialog();

                    if (form.YES)
                    {
                        if (!productRepository.Delete(selectedRowId))
                        {
                            MessageBox.Show("Gagal menghapus barang");
                        }
                        LoadData();
                    }
                }
                else
                {
                    var form = new ConfirmationDialog();
                    form.Message = "Apa anda yakin menghapus barang terpilih?";
                    form.ShowDialog();

                    if (form.YES)
                    {
                        if (!productRepository.Delete2table(selectedRowId))
                        {
                            MessageBox.Show("Gagal menghapus barang");
                        }
                        LoadData();
                    }
                }
            }
        }
        public ActionResult DeleteConfirm(int id)
        {
            bool result = ProductRepo.Delete(id);

            if (result)
            {
                return(Json(new
                {
                    success = result,
                    entity = "",
                    message = "Data Deleted! Data Product has been deleted!"
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new
                {
                    success = result,
                    entity = "",
                    message = "Delete Failed!!!"
                }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #11
0
 public void Remove(Product t)
 {
     repo.Delete(t);
 }
Exemple #12
0
 public IActionResult Delete(Product product)
 {
     ProductRepo.Delete(product);
     TempData["message"] = $"Deleted Product {product.Name}.";
     return(RedirectToAction("List", "Product"));              // Redirect
 }
 public static void deleteProduct(int productId)
 {
     ProductRepo.Delete(productId);
 }
Exemple #14
0
 public void DeleteProduct(Product product)
 {
     productRepo.Delete(product);
 }
Exemple #15
0
 public void Delete(int id)
 {
     productRepo.Delete(id);
 }
Exemple #16
0
 public void DeleteProduct(Guid ProductId)
 {
     ProductRepo.Delete(ProductId);
 }
        public Product Delete(Product product)
        {
            var repo = new ProductRepo(_context);

            return(repo.Delete(product));
        }
Exemple #18
0
 [HttpPost]//Message when tech deleted, save changes, and return to tech page
 public IActionResult Delete(Product product)
 {
     ProductRepo.Delete(product);
     TempData["message"] = $"{product.Name} deleted from database";
     return(RedirectToAction("List", "Product"));
 }
Exemple #19
0
 public bool Delete(Product product)
 {
     return(_productRepo.Delete(product));
 }
Exemple #20
0
 public ActionResult DeleteConfirmed(int id)
 {
     repo.Delete(id);
     return(RedirectToAction("Index"));
 }