Exemplo n.º 1
0
        public async Task <IActionResult> Delete(int id)
        {
            if (!HttpContext.Session.GetInt32("authenticated").HasValue)
            {
                return(new RedirectToActionResult("index", "login", null));
            }

            await categoryModel.DeleteCategory(id);

            return(new RedirectToActionResult("index", "category", null));
        }
Exemplo n.º 2
0
 public ActionResult DeleteCategory()
 {
     if (Session["admin"] == null)
     {
         Response.Redirect("~/Admin2/Home/Login");
     }
     try
     {
         int id = Convert.ToInt32(Request.Params["id"]);
         cat.DeleteCategory(id);
     }
     catch
     {
     }
     return(View("CategoryTable", cat.SelectCategory()));
 }
Exemplo n.º 3
0
        public HttpResponseMessage Delete(int id)
        {
            HttpResponseMessage responseMessage;

            bool response = categoryModel.DeleteCategory(id);

            if (response)
            {
                SuccessMessage msg = new SuccessMessage("deleted");
                responseMessage = Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                responseMessage = Request.CreateResponse(HttpStatusCode.ExpectationFailed);
            }

            return(responseMessage);
        }
Exemplo n.º 4
0
        public HttpResponseMessage Delete(int id)
        {
            HttpResponseMessage responseMessage;
            JSendMessage        json;
            bool response = categoryModel.DeleteCategory(id);

            if (response)
            {
                json            = new JSendMessage("success", "Category successfully deleted");
                responseMessage = Request.CreateResponse(HttpStatusCode.OK, json);
            }
            else
            {
                json            = new JSendMessage("fail", "Something bad happened");
                responseMessage = Request.CreateResponse(HttpStatusCode.BadRequest, json);
            }

            return(responseMessage);
        }
Exemplo n.º 5
0
 public ActionResult DeleteCategory(int id, string sort = "", int page = 0)
 {
     if (Convert.ToInt32(Session["UserRollId"]) == 1)
     {
         CategoryModel categories = new CategoryModel();
         if (sort != "" && page != 0)
         {
             var Categories = categories.GetCategory();
             return(View("CategoryList", Categories));
         }
         else
         {
             categories.DeleteCategory(id);
             return(Redirect("/Admin/CategoryList"));
         }
     }
     else
     {
         return(Redirect("/Admin/index"));
     }
 }
 protected void repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Delete")
         {
             CategoryModel objresult = new CategoryModel();
             int           id        = Convert.ToInt32(e.CommandArgument);
             objresult.DeleteCategory(id);
             var result = objresult.GetCategory();
             repeater2.DataSource = result;
             repeater2.DataBind();
         }
         if (e.CommandName == "Edit")
         {
             int id = Convert.ToInt32(e.CommandArgument);
             Response.Redirect("AddCategory.aspx?id=" + id);
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(" + ex.Message + ")", true);
     }
 }
Exemplo n.º 7
0
 // Post: Category/Delete/5
 public ActionResult Delete(int id)
 {
     CategoryModel.DeleteCategory(id);
     return(RedirectToAction("index"));
 }
Exemplo n.º 8
0
 public bool DeleteCategory(int _ID_CATEGORY, int _ID_USER)
 {
     return(categoryModel.DeleteCategory(_ID_CATEGORY, _ID_USER));
 }