public IHttpActionResult DeleteEmployee(int id) { var employee = repo.GetById(id); if (employee == null) { return(Content(HttpStatusCode.NotFound, "Item does not exist")); } repo.Delete(employee); return(Ok(employee)); }
public ActionResult DeleteConfirm(Employee employee) { try { employees.Delete(employee); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError(String.Empty, ex); } return(View(employee)); }
private void BtnDelete_Click(object sender, EventArgs e) { try { empRepo.Delete(GetEmp()); } catch (Exception ex) { BAL.Exc.ErMessage(ex); } finally { TLPCRUD.Enabled = false; DGVEmployee.DataSource = empRepo.View(); } }
private void BtnDelete_Click(object sender, EventArgs e) { try { var emp = GetEmployee(); if (emp != null) { empRepo.Delete(emp); LoadDGV(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
public async Task <IActionResult> DeleteEmployee([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var emp = await _context.GetById(id); if (emp == null) { return(NotFound()); } var employee = await _context.Delete(emp); return(Ok(employee)); }
private void btnDeleteUser_Click(object sender, EventArgs e) { string userType = this.dgvUsersGrid.CurrentRow.Cells["user_type"].Value.ToString(); if (userType == "Admin") { MessageBox.Show("Can not delete admin"); return; } if (this.dgvUsersGrid.SelectedRows.Count < 1) { MessageBox.Show("No row selected"); return; } string appId = this.dgvUsersGrid.CurrentRow.Cells["appid"].Value.ToString(); string name = this.dgvUsersGrid.CurrentRow.Cells["full_name"].Value.ToString(); if (MessageBox.Show($"Do you want to delete {name}?", "Confirmation", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } try { if (EmployeeRepo.Delete(appId) && LoginRepo.Delete(appId) && UserRepo.Delete(appId)) { MessageBox.Show(name + " has been deleted successfully"); this.PopulateGridView(); this.dgvUsersGrid.ClearSelection(); this.dgvUsersGrid.Refresh(); this.ClearUserInput(); } } catch (Exception a) { MessageBox.Show("Error!" + a.Message); } }
public ActionResult DeleteConfirm(int id) { bool result = EmployeeRepo.Delete(id); if (result) { return(Json(new { success = result, entity = "null", message = "Delete Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = result, entity = "null", message = "Delete Failed" }, JsonRequestBehavior.AllowGet)); } }
public void TestMethodDelete() { OptionInstance.ConfigAutomapper(); EmployeeRepo repo = new EmployeeRepo(@"Persist Security Info=False;Integrated Security=true;Initial Catalog=RJD.Test;Server=localhost"); var createDto = new EmployeeDto { Id = Guid.NewGuid(), Name = "Иван", Surname = "Иванов", BornDate = new DateTime(2019, 8, 12, 20, 22, 59) }; repo.Create(createDto); bool isCreated = !repo.Read(createDto.Id).IsNull(); repo.Delete(createDto); var readDto = repo.Read(createDto.Id); Assert.IsTrue(isCreated && readDto.IsNull()); }
public int deleteEmployee(string id) { int result = empr.Delete(id); return(result); }
// DELETE api/<controller>/5 public Responses Delete(int id) { return(EmployeeRepo.Delete(id)); }
public ActionResult Delete(int id) { EmployeeRepo.Delete(id); return(RedirectToAction("Index")); }