// GET: Deliveries/Delete/5 public ActionResult Delete(int id) { if (id < 1) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeContainer.DeleteEmployee(id); return(RedirectToAction("Index")); }
public static void Remove() { EmployeeContainer employeeContainer = EmployeeContainer.Inst; List <Employee> employees = employeeContainer.GetEmployees(); Validation validation = new Validation(); string id = String.Empty; do { Console.Write("Enter id of employee you want to delete:"); id = Console.ReadLine(); validation.CheckIntegerInput(id); } while (!validation.inputIsValid); Int32.TryParse(id, out int intId); for (int i = employees.Count - 1; i >= 0; i--) { if (employees[i].Id == intId) { employeeContainer.DeleteEmployee(employees[i]); Console.WriteLine("Employee deleted"); } } }