public IHttpActionResult DeleteEmployee(int id) { Emp obj = new Emp(); bool result = obj.Delete(id); if (result) { return(Ok()); } else { return(NotFound()); } //Employee employee = db.Employees.Find(id); //if (employee == null) //{ // return NotFound(); //} //db.Employees.Remove(employee); //db.SaveChanges(); //return Ok(employee); }
private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("ต้องการจะลบข้อมูล ใช่หรือไม่", "ลบ?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { emp1.Delete(int.Parse(inbID.Text)); } selectEmpsMyCombo_SelectedIndexChanged(sender, e); empListBox_SelectedValueChanged(sender, e); }
public ActionResult Delete(int id, FormCollection collection) { try { Emp model = Emp.GetById(id); model.Delete(); return(RedirectToAction("Index")); } catch (Exception e) { ViewBag.error = e.ToString(); return(View()); } }