// DELETE: api/Department/5 public async Task <IHttpActionResult> Delete(int id) { try { if (id <= 0) { return(BadRequest()); } var DepartmentToBeDeleted = await DepartmentManager.GetById(id); if (DepartmentToBeDeleted == null) { return(NotFound()); } await DepartmentManager.Delete(id); return(Ok()); } catch (Exception ex) { Console.WriteLine(ex); return(InternalServerError()); } }
public ActionResult Delete(Department department) { var departmentManager = new DepartmentManager(); departmentManager.Delete(department); return(RedirectToAction("Index")); }
public ActionResult DeleteDepartmentConfirmed(int id) { if (employeeManager.Find(y => y.DepartmentId == id) != null) { ErrorViewModel ntfobj = new ErrorViewModel() { Title = "Error", RedirectingUrl = "/Home/ListDepartment", RedirectingTimeout = 3000 }; ErrorMessageObj obj = new ErrorMessageObj(ErrorMessageCode.EmployeeIsADirector, "There are employees in your chosen department..!"); ntfobj.Items.Add(obj); return(View("Error", ntfobj)); } else { Department d = departmentManager.Find(x => x.DepartmentId == id); if (departmentManager.Delete(d) > 0) { OkViewModel ntfobj = new OkViewModel() { Title = "Delete Successful", RedirectingUrl = "/Home/ListDepartment/", RedirectingTimeout = 1000 }; ntfobj.Items.Add("Department delete was successful.."); return(View("Ok", ntfobj)); } return(RedirectToAction("ListDepartment")); } }
private void DeleteDepartment() { if (departmentBindingSource == null) { return; } var dResult = MessageBox.Show(@"Delete current record?", @"Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dResult != DialogResult.Yes) { return; } if (DepartmentManager.Delete(((Department)departmentBindingSource.Current).DepartmentId)) { MessageBox.Show(@"Record was deleted successfully.", @"Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); departmentBindingSource.RemoveCurrent(); } else { MessageBox.Show(@"Error on delete operation.", @"Delete", MessageBoxButtons.OK, MessageBoxIcon.Error); departmentDataGridView.Focus(); } }
public JsonResult Delete(Int64 Id) { if (departmentManager.Delete(Id)) { return(Json(new { info = "Deleted", status = true }, JsonRequestBehavior.AllowGet)); } return(Json(new { info = "Not Deleted", status = false }, JsonRequestBehavior.AllowGet)); }
public IActionResult Delete(int?id) { bool isSaved = departmentManager.Delete(id); if (isSaved) { return(RedirectToAction("List", "Department", null)); } return(View("List")); }
internal static void Delete(IDataStore dataStore, IDepartmentModel department) { DepartmentManager manager = new DepartmentManager(dataStore); int num = manager.Delete(department.ApplicationId, department.DepartmentId); Assert.GreaterOrEqual(num, 1); Assert.IsNull(manager.GetDepartment(department.ApplicationId, department.DepartmentId)); Trace.WriteLine("Successfully deleted department " + department.Name); }
public void Delete_WhenDeletedDepartment_ShouldUpdateEnableStatus() { // Arrange var departmentId = 1; var mockDepartmentDal = new MockDepartmentDal().MockUpdate().MockGet(new Department()); var sut = new DepartmentManager(mockDepartmentDal.Object); // Act sut.Delete(departmentId); // Assert mockDepartmentDal.VerifyUpdate(Times.Once()); }
private void BtnDelete_Click(object sender, EventArgs e) { if (department == null) { MessageBox.Show("Departman Seçiniz"); return; } DialogResult dr = MessageBox.Show(department.Name + " Departmanıyla İlgili Silme İşlemi Yapılacaktır. Onaylıyor Musunuz ?", "Soru", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { MessageBox.Show(departmentManager.Delete(department.Id)); DepartmentList(); } }
public JsonResult Delete(int id) { _deptManager.Delete(id); return(null); }