static void Main(string[] args) { DatabaseHandlerFactory factory = new DatabaseHandlerFactory(); Console.WriteLine("Enter Input as described below:"); Console.WriteLine("Enter " + (int)Databases.SQL + " to create a SQL database handler for employee"); Console.WriteLine("Enter " + (int)Databases.MYSQL + " to create a MYSQL database handler for employee"); Console.WriteLine("Enter " + (int)Databases.NOSQL + " to create a NOSQL database handler for employee"); Console.WriteLine("Input: "); EmployeeDatabaseHandler handler = null; var input = Console.ReadLine(); int database = int.Parse(input); if (database == (int)Databases.MYSQL) { handler = factory.createEmployeeDatabaseHandler(Databases.MYSQL); } else if (database == (int)Databases.SQL) { handler = factory.createEmployeeDatabaseHandler(Databases.SQL); } else { handler = factory.createEmployeeDatabaseHandler(Databases.NOSQL); } handler.CreateEmployee(); handler.DeleteEmployee(); handler.GetEmployee(); handler.UpdateEmployee(); }
static void Main(string[] args) { DatabaseHandlerFactory factory; Console.WriteLine("Enter Input as described below:"); Console.WriteLine("Enter " + (int)Databases.SQL + " to create a SQL database handler for employee"); Console.WriteLine("Enter " + (int)Databases.MYSQL + " to create a MYSQL database handler for employee"); Console.WriteLine("Enter " + (int)Databases.NOSQL + " to create a NOSQL database handler for employee"); Console.WriteLine("Input: "); DatabaseHandler handler = null; var input = Console.ReadLine(); int database = int.Parse(input); if (database == (int)Databases.MYSQL) { factory = MYSQLDatabaseHandlerFactory.GetInstance(); } else if (database == (int)Databases.NOSQL) { factory = NOSQLDatabaseHandlerFactory.GetInstance(); } else { factory = SQLDatabaseHandlerFactory.GetInstance(); } EmployeeDatabaseHandler employeeHandler = factory.GetDatabaseHandler().GetEmployeeDatabaseHandler(); DepartmentDatabaseHandler departmentHandler = factory.GetDatabaseHandler().GetDepartmentDatabaseHandler(); employeeHandler.CreateEmployee(); employeeHandler.DeleteEmployee(); employeeHandler.GetEmployee(); employeeHandler.UpdateEmployee(); departmentHandler.CreateDepartment(); departmentHandler.DeleteDepartment(); departmentHandler.GetDepartment(); departmentHandler.UpdateDepartment(); }