public void EmployeeMenuFiltered() { int?choice = MenuUtils.GetIntChoice(MenuUtils.EmployeeFilterMenu(), 1, 3); switch (choice) { case 1: EmployeeMenuFilteredByLastname(); break; case 2: EmployeeMenuFilteredByFunction(); break; case 3: EmployeeMenu(); break; default: break; } }
public static void AllEmployeesMenu() { int?allEmployeesMenuChoice = MenuUtils.GetIntChoice(MenuUtils.AllEmployeesMenu(), 1, 3); switch (allEmployeesMenuChoice) { case 1: using (var db = new EmployeeContext()) { foreach (var item in db.employees) { Console.WriteLine("Lastname : {0}, Firstname : {1}, Function : {2}.", item.LastName, item.FirstName, item.Function); } } break; case 2: Payroll(); break; case 3: Menu.EmployeesMenu(); break; default: Menu.AllEmployeesMenu(); break; } }
private void CUDService() { int?choice = MenuUtils.GetIntChoice(MenuUtils.CUDService(), 1, 4); switch (choice) { case 1: CreateService(); break; case 2: //UpdateService(); break; case 3: DeleteService(); break; case 4: ServiceMenu(); break; default: CUDService(); break; } }
private void CUDEmployee() { int?choice = MenuUtils.GetIntChoice(MenuUtils.CUDEmployeeChoice(), 1, 4); switch (choice) { case 1: CreateEmployee(); break; case 2: UpdateEmployee(); break; case 3: DeleteEmployee(); break; case 4: EmployeeMenu(); break; default: CUDEmployee(); break; } }
public static void MainMenu() { int?menuChoice = null; do { menuChoice = MenuUtils.GetIntChoice(MenuUtils.BaseChoiceMenu(), 1, 4); switch (menuChoice) { case 1: Menu.EmployeesMenu(); break; case 2: Menu.ServicesMenu(); break; case 3: Payroll(); break; case 4: Console.WriteLine("Enter to close this application. Thank you and good bye."); Console.ReadLine(); break; default: MainMenu(); break; } } while (menuChoice != 4); }
public void EmployeeMenu() { int?choice = MenuUtils.GetIntChoice(MenuUtils.EmployeeMenu(), 1, 4); PrintFromDb <Employee>((EmployeeContext db) => { return(db.Employees.AsNoTracking().ToList()); }); switch (choice) { case 1: SalaryChargeMenu((EmployeeContext db) => { return(db.Employees.AsNoTracking().Sum(x => x.Salary)); }, EmployeeMenu); break; case 2: EmployeeMenuFiltered(); break; case 3: CUDEmployee(); break; case 4: MainMenu(); break; default: break; } }
private void DeleteEmployee() { using (var db = new EmployeeContext()) { foreach (var item in db.Employees.ToList()) { Console.WriteLine(item); } // Employee choosen to delete Employee deletedEmployee = null; long response; // EmployeeToDelete contient l'instance à supprimer do { Console.WriteLine("Choose the id employee you want to delete"); long.TryParse(Console.ReadLine(), out response); deletedEmployee = db.Employees.Find(response); } while (deletedEmployee == null); // sure ? int?choice; do { choice = MenuUtils.GetIntChoice(MenuUtils.deletedEmployeeChoice(), 1, 3); switch (choice) { case 1: // delete db.Entry(deletedEmployee).State = EntityState.Deleted; break; case 2: DeleteEmployee(); break; case 3: CUDEmployee(); break; } } while (choice != 1 || choice != 2 || choice != 3); db.SaveChanges(); } }
public void MainMenu() { int?choice = null; do { choice = MenuUtils.GetIntChoice(MenuUtils.BaseChoiceMenu(), 1, 4); switch (choice) { case 1: EmployeeMenu(); break; case 2: ServiceMenu(); break; case 3: using (var db = new EmployeeContext()) { Console.WriteLine(db.Employees.AsNoTracking().Sum(x => x.Salary)); } break; case 4: Environment.Exit(0); break; default: break; } } while (true); }
public void SalaryChargeMenu(Func <EmployeeContext, float> func, Action backMenu) { int?choice = MenuUtils.GetIntChoice(MenuUtils.SalaryChargeMenu(), 1, 2); switch (choice) { case 1: using (var db = new EmployeeContext()) { try { Console.WriteLine(func.Invoke(db) + "€"); } catch (Exception e) { Console.WriteLine(e); } } break; case 2: backMenu.Invoke(); break; default: break; } }
public static void EmployeesMenu() { int?employeesMenuChoice = MenuUtils.GetIntChoice(MenuUtils.EmployeesMenu(), 1, 3); switch (employeesMenuChoice) { case 1: Menu.AllEmployeesMenu(); break; case 2: Menu.SpecificEmployeesMenu(); break; case 3: MainMenu(); break; default: Menu.EmployeesMenu(); break; } }
public static void ServiceNameChoice(string value) { int?listOrPayroll = MenuUtils.GetIntChoice(MenuUtils.ListOrPayroll(), 1, 3); switch (listOrPayroll) { case 1: //EmployeesOfSelectedService(value); break; case 2: //PayrollOfSelectedService(value); break; case 3: Menu.ServicesMenu(); break; default: Menu.ServiceNameChoice(value); break; } }
public static void SelectByLastNameMenu() { int?lastNameMenuChoice = MenuUtils.GetIntChoice(MenuUtils.LastnameMenu(), 1, 3); switch (lastNameMenuChoice) { case 1: ListSelectedEmployees(); break; case 2: PayrollSelectedEmployees(); break; case 3: SpecificEmployeesMenu(); break; default: Menu.SelectByLastNameMenu(); break; } }
public static void SelectByFunctionMenu() { int?FunctionMenuChoice = MenuUtils.GetIntChoice(MenuUtils.FunctionMenu(), 1, 3); switch (FunctionMenuChoice) { case 1: SelectByFunction(); ListSelectedEmployeesByFunction(); break; case 2: PayrollSelectedEmployeesByFunction(); break; case 3: SpecificEmployeesMenu(); break; default: Menu.SelectByFunctionMenu(); break; } }
public static void SpecificEmployeesMenu() { int?specificEmployeesMenuChoice = MenuUtils.GetIntChoice(MenuUtils.SpecificEmployeesMenu(), 1, 3); switch (specificEmployeesMenuChoice) { case 1: SelectByLastName(); Menu.SelectByLastNameMenu(); break; case 2: SelectByFunction(); break; case 3: Menu.EmployeesMenu(); break; default: Menu.SpecificEmployeesMenu(); break; } }
public static void ServicesMenu() { int?serviceNameChoice = MenuUtils.GetIntChoice(MenuUtils.ServicesMenu(), 1, 10); switch (serviceNameChoice) { case 1: string nameService = "serviceName 1"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 2: nameService = "serviceName 2"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 3: nameService = "serviceName 3"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 4: nameService = "serviceName 4"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 5: nameService = "serviceName 5"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 6: nameService = "serviceName 6"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 7: nameService = "serviceName 7"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 8: nameService = "serviceName 8"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 9: nameService = "serviceName 9"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 10: nameService = "serviceName 10"; Console.WriteLine("Choosen service : {0}", nameService); ServiceNameChoice(nameService); break; case 11: MainMenu(); break; default: Menu.ServicesMenu(); break; } }
private void DeleteService() { using (var db = new EmployeeContext()) { foreach (var item in db.services.ToList()) { Console.WriteLine(item); } // Service choosen to delete Service deletedService = null; long response; // serviceToDelete contient l'instance à supprimer do { Console.WriteLine("Choose the id service you want to delete"); long.TryParse(Console.ReadLine(), out response); deletedService = db.services.Find(response); } while (deletedService == null); // sure ? int?choice; do { choice = MenuUtils.GetIntChoice(MenuUtils.deletedServiceChoice(), 1, 3); switch (choice) { case 1: // delete all affected employees // or // affecte a new id service for the employee who lost their id service ? int?newIdServiceChoice; do { newIdServiceChoice = MenuUtils.GetIntChoice(MenuUtils.NewIdServiceChoice(), 1, 4); switch (newIdServiceChoice) { case 1: AffectedNewIdServiceAllEmployees(deletedService); break; case 2: AffectedNewIdServiceEachEmployees(deletedService); break; case 3: DeleteAllAffectedEmployees(deletedService); break; case 4: DeleteService(); break; } } while (newIdServiceChoice != 1 || newIdServiceChoice != 2 || newIdServiceChoice != 3 || newIdServiceChoice != 4); ; break; case 2: DeleteService(); break; case 3: CUDService(); break; } } while (choice != 1 || choice != 2 || choice != 3); // save db.SaveChanges(); } }
private void ServiceMenu() { PrintFromDb <Service>((EmployeeContext db) => { return(db.Services.AsNoTracking().ToList()); }); int?serviceId = MenuUtils.GetIntChoice("Choose service by id", 1, int.MaxValue); int?choice = MenuUtils.GetIntChoice(MenuUtils.ServiceMenu(), 1, 4); Console.WriteLine("Service " + serviceId + " selected"); PrintFromDb <Service>((EmployeeContext db) => { return(db.Services.AsNoTracking().Where(x => x.ServiceId == serviceId).ToList()); }); switch (choice) { case 1: PrintFromDb <Employee>((EmployeeContext db) => { return(db.Employees.AsNoTracking().Where(x => x.Department.ServiceId == serviceId).ToList()); }); SalaryChargeMenu((EmployeeContext db) => { return(db.Employees.AsNoTracking().Include(x => x.Department).Where(x => x.Department.ServiceId == serviceId).Sum(x => x.Salary)); }, ServiceMenu); break; case 2: using (var db = new EmployeeContext()) { if (db.Employees.Include(x => x.Department).Where(x => x.Department.ServiceId == serviceId).Count() > 0) { Console.WriteLine(db.Employees.Include(x => x.Department).Where(x => x.Department.ServiceId == serviceId).Sum(x => x.Salary)); } } break; case 3: CUDService(); break; case 4: MainMenu(); break; default: break; } }