public void Run() { Console.Clear(); Components.Title("DELETE ENDPOINT:"); Console.WriteLine("Enter the serial number of the Endpoint to be deleted:"); var result = Console.ReadLine(); var endPoint = _endPointDao.Find(result); if (endPoint != null) { Console.WriteLine(); Console.WriteLine("EndPoint in editing:"); Console.WriteLine(endPoint.ToString()); Console.WriteLine(); string typeit; do { Console.Write("Proceed with the exclusion? (Y/N):"); typeit = Console.ReadLine(); } while (typeit.ToUpper() != "Y" && typeit.ToUpper() != "N"); if (typeit.ToUpper() == "Y") { _endPointDao.Delete(endPoint); Console.WriteLine(@" EndPoint Deleted! Press Enter to return..."); Console.ReadKey(); } } else { Console.WriteLine("EndPoint not found. Press Enter to return..."); Console.ReadKey(); } }
public bool Delete(EndPoint obj) { try { if (_endPointDAO.Find(obj.SerialNumber) == null) { throw new Exception("Sorry! EndPoint not found.."); } _endPointDAO.Delete(obj); return(true); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(ex.Message); return(false); } }