public IActionResult SearchBarMethod(string SearchBarEmployee) { if (Startup.isLogged == true) { try { list = EmployeeAbstractizationFactory.ReturningEmployeesList(); List <IEmployeeModel> SearchList = new List <IEmployeeModel>(); foreach (DatabaseClassLibrary.EmployeesDatabase.IEmployeeModel individ in list) { if (individ.FullName.Contains(SearchBarEmployee)) { SearchList.Add(individ); Console.WriteLine(individ.FullName); Console.WriteLine(SearchList.Count().ToString()); } } return(View("Employees", SearchList)); } catch (Exception ex) { return(View(list)); } } else { return(RedirectToAction("Login", "Login")); } }
public static void Main(string[] args) { IEmployeesDatabaseConnection EmployeesDatabaseConnection = EmployeeAbstractizationFactory.CreateEmployeeDatabaseConnection(); EmployeesDatabaseConnection.SetConnectionToLocalDatabase(); IRecordsDatabaseConnection RecordsDatabaseConnection = RecordsAbstractizationFactory.CreateRecordsDatabaseConnection(); RecordsDatabaseConnection.SetConnectionToLocalDatabase(); IEmployeeDatabaseCRUD EmployeesCRUDOperations = EmployeeAbstractizationFactory.CreateInstanceForCRUDOperations(); IRecordsDatabaseCRUD RecordsCRUDOperations = RecordsAbstractizationFactory.CreateInstanceForCRUDOperations(); IEmployeeModel vasile = EmployeeAbstractizationFactory.CreateEmployeeInstance("vasile1", "10.11.1128", "Wheel", "10.2.2008"); for (int i = 1; i < 2; i++) { vasile = EmployeeAbstractizationFactory.CreateEmployeeInstance((string)("vasile" + i.ToString()), "10.11.1128", "Wheel", "10.2.2008"); EmployeesCRUDOperations.AddNewEmployeeToDatabase(vasile); } CreateHostBuilder(args).Build().Run(); }
public IActionResult EditEmployeeButton(int id) { if (Startup.isLogged == true) { try { list = EmployeeAbstractizationFactory.ReturningEmployeesList(); IEmployeeModel Dummy = list.Find(x => x.ID == id); Dummy.ID = id; Console.WriteLine(Dummy.ID.ToString() + "----->" + Dummy.ID.ToString() + Dummy.FullName); return(View("EditEmployee", Dummy)); } catch (Exception ex) { Console.WriteLine(ex); return(RedirectToAction("Error")); } } else { return(RedirectToAction("Login", "Login")); } }
public IActionResult Employees(List <IEmployeeModel> model) { if (Startup.isLogged == true) { if (model.Count == 0) { list = EmployeeAbstractizationFactory.ReturningEmployeesList(); return(View(list)); } else { return(View(model)); } } else { return(RedirectToAction("Login", "Login")); } }
public IActionResult SaveModificationEmployee(int ID, string FullName, string BirthDay, string Qualification, string FirstDay) { if (Startup.isLogged == true) { try { IEmployeeModel Dummy = EmployeeAbstractizationFactory.CreateEmployeeInstance(ID, FullName, BirthDay, Qualification, FirstDay); Console.WriteLine(Dummy.ID.ToString() + "->" + Dummy.FullName + " " + Dummy.BirthDay); EmployeesCRUDOperations.UpdateEmployeeInDatabase(Dummy); return(RedirectToAction("Employees")); } catch (Exception ex) { Console.WriteLine(ex); return(RedirectToAction("Error")); } } else { return(RedirectToAction("Login", "Login")); } }
public IActionResult AddNewEmployeeSubmitButton(string FullNameInput, string BirthDayInput, string QualificationInput, string FirstDayInput) { Console.WriteLine(FullNameInput + " " + BirthDayInput + " " + QualificationInput + " " + FirstDayInput); if (Startup.isLogged == true) { try { IEmployeeModel Dummy = EmployeeAbstractizationFactory.CreateEmployeeInstance(FullNameInput, BirthDayInput, QualificationInput, FirstDayInput); EmployeesCRUDOperations.AddNewEmployeeToDatabase(Dummy); return(RedirectToAction("Employees")); } catch (Exception ex) { return(RedirectToAction("Error")); } } else { return(RedirectToAction("Login", "Login")); } }