public ActionResult DeleteItem(int id)
 {
     //try to connect to server, and delete item by id
     try
     {
         //delete item by id
         iDAO.DeleteItem(id);
     }
     //catch and log any unlogged sqlExceptions
     catch (SqlException sqlEx)
     {
         if (!((bool)sqlEx.Data["Logged"] == true) || !sqlEx.Data.Contains("Logged"))
         {
             Logger.LogSqlException(sqlEx);
         }
     }
     catch (Exception ex)
     {
         if (!ex.Data.Contains("Logged") || (bool)ex.Data["Logged"] == false)
         {
             Logger.LogException(ex);
         }
     }
     //return to Items home page
     return(RedirectToAction("Index", "Item"));
 }
Beispiel #2
0
        private void btnDeleteItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Delete this item ? \n Item Id : " + this.dgvItemData.SelectedRows[0].Cells[0].Value.ToString() + "\n Item Name : " + this.dgvItemData.SelectedRows[0].Cells[1].Value.ToString(), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                dao.DeleteItem(this.dgvItemData.SelectedRows[0].Cells[0].Value.ToString());

                ReloadDGVData();
            }
        }
Beispiel #3
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            if (id == 0)
            {
                return(BadRequest("Id needed"));
            }

            var success = await Dao.DeleteItem(id);

            if (!success)
            {
                return(NotFound());
            }
            return(Ok());
        }
Beispiel #4
0
 public ActionResult DeleteItem(int data)
 {
     ItemDAO.DeleteItem(Convert.ToInt32(data));
     return(RedirectToAction("Tables"));
 }
Beispiel #5
0
 public ActionResult Delete(int id)
 {
     dao.DeleteItem(id);
     return(RedirectToAction("Index"));
 }