public void CanDeleteEmployee() { var employee = _repository.FindOne(x => x.FirstName == "UpdateTest"); var result = _repository.Delete(employee); Assert.NotNull(result); }
public ActionResult Delete(int id) { EmployeesRepository repo = new EmployeesRepository(); repo.Delete(id); return(RedirectToAction("Index", "Employees")); }
public void Delete(ObjectListView olv) { var obj = olv.SelectedObject as Employee; using (EmployeesRepository repo = new EmployeesRepository()) { repo.Delete(obj); olv.RemoveObject(obj); } }
public ActionResult Delete(int id) { if (ModelState.IsValid) { repository.Delete(id); } return(RedirectToAction("Index", "Home")); }
public ActionResult Delete(int id, EmployeeModel model) { try { // TODO: Add delete logic here employees.Delete(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void EmployeesRepositoryTests_Delete() { EmployeesRepository repository = new EmployeesRepository(); var employees = new Employees() { Account = "Tom" }; repository.Delete("Tom"); var result = repository.GetByEmployeesAccount("Tom"); Assert.IsTrue(result.Account == null); }
public ActionResult Delete(int id) { if (id <= 0) { return(BadRequest(_translationService.Translate(Request.Headers, "EC7"))); } try { _employeesRepository.Delete(id); _employeesRepository.SaveChanges(); } catch (Exception ex) { return(BadRequest(_translationService.TranslateException(ex, Request.Headers))); } return(Ok(id)); }
private void btnDelete_Click(object sender, EventArgs e) { EmployeesRepository repository = new EmployeesRepository(); try { repository.Delete(new SqlParameter("FirstName", txtFirstName.Text), new SqlParameter("LastName", txtLastName.Text), new SqlParameter("Role", txtRole.Text), new SqlParameter("Salary", txtSalary.Text) ); DialogResult = DialogResult.OK; MessageBox.Show("მონაცემები წაშლილია"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult Delete(int id, Employee employee) { if (id != employee.Id) { return(BadRequest()); } if (_repository.GetById(id) == null) { return(NotFound()); } try { _repository.Delete(employee); return(RedirectToAction(nameof(Index))); } catch { return(View(employee)); } }