Пример #1
0
        public JsonResult DeleteBrand(int id)
        {
            UserLogin user = (UserLogin)Session[CommonConstants.USER_SESSION];
            //check for prouduct exits on brand
            string messageDelete = "";
            bool   resultDelete  = false;
            var    lstProduct    = ProductDAO.GetListProductByBrandID(id, 1);

            if (lstProduct.Count > 0)
            {
                resultDelete  = false;
                messageDelete = "Hiện đang có " + lstProduct.Count + " sản phẩm thuộc Brand này. Không thể xóa!";
            }
            else
            {
                resultDelete  = BrandModel.DeleteBrand(id, user.UserID.ToString());
                messageDelete = "Xóa thành công";
                SetAlert($"Xóa Brand {id} thành công", "success");
            }


            return(Json(
                       new
            {
                status = resultDelete,
                message = messageDelete
            }));
        }
Пример #2
0
 public ActionResult DeleteBrand()
 {
     if (Session["admin"] == null)
     {
         Response.Redirect("~/Admin2/Home/Login");
     }
     try
     {
         int id = Convert.ToInt32(Request.Params["id"]);
         br.DeleteBrand(id);
     }
     catch
     {
     }
     return(View("TableBrand", br.SelectListBrand()));
 }