public ActionResult Delete(EmployeeModels model) { try { string msg = ""; var result = _factory.Delete(model.ID, CurrentUser.UserId, ref msg); if (!result) { ModelState.AddModelError("Name", msg); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Delete", model)); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); } catch (Exception ex) { NSLog.Logger.Error("Employee_Delete: ", ex); ModelState.AddModelError("Name", "Have an error when you delete a Employee"); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Delete", model)); } }
private void btnNext_Click(object sender, RoutedEventArgs e) { string name = RName(); EmployeeFactory obj = new EmployeeFactory(); bool result = obj.Delete(name); if (result) { MessageBox.Show("Data is Deleted ", "Deleted"); this.Close(); } else { MessageBox.Show("Data is not Deleted Something is wrong", "Error!"); } }