public EmployeeAddEdit() { InitializeComponent(); this.CantHoras.Visible = false; _IBL = new BLEmployees(new DALEmployeesMock()); }
private static void SetupDependencies() { IUnityContainer container = new UnityContainer(); container.LoadConfiguration(); blHandler = container.Resolve <IBLEmployees>(); //blHandler = new BLEmployees(new DataAccessLayer.DALEmployeesEF()); }
public void CalcPartTimeEmployeeSalaryTestMethod() { InitTest(); //arrange int hours = 10; IBLEmployees blHandler = container.Resolve <IBLEmployees>(); List <Employee> partTimeEmployees = blHandler.GetAllEmployees().Where(emp => emp is PartTimeEmployee).ToList(); //act var sum = partTimeEmployees.Sum(emp => blHandler.CalcPartTimeEmployeeSalary(emp.IdEmployee, hours)); //assert Assert.AreEqual(sum, 10000); }
public EmployeeAddEdit(Employee emp) { InitializeComponent(); this.CantHoras.Visible = false; this.edit = true; if (emp != null) { if (emp is PartTimeEmployee) { part = (PartTimeEmployee)emp; this.LoadTextPart(part); this.CantHoras.Visible = true; } else { full = (FullTimeEmployee)emp; this.LoadTextFull(full); this.CantHoras.Visible = false; } } _IBL = new BLEmployees(new DALEmployeesMock()); }
private static void SetupDependencies() { blHandler = new BLEmployees(new DataAccessLayer.DALEmployeesEF()); }
public EmployeeController() { IDALEmployees dal = new DALEmployeesEF(); _bl = new BLEmployees(dal); }
public ServiceEmployees() { blHandler = Program.blHandler; }
public ServiceEmployees() { blHandler = new BLEmployees(new DALEmployeesEF()); }
static void Main(string[] args) { //log4net.Config.XmlConfigurator.Configure(); //log4net.Config.XmlConfigurator.Configure(new FileInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\RtdServer.dll.config")); //log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); log.Info("========================================"); log.Info("Comienzo Programa. Fecha : " + System.DateTime.Now.ToString()); var section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity"); IUnityContainer container = new UnityContainer().LoadConfiguration(section); //section.Configure(container); //Helper.RegisterTypes(container); IBLEmployees handler = container.Resolve <IBLEmployees>(); int opcion; string nombre; char tipoEmpleado; int numeradorId = 0; double precioHora; int salario; do { Console.WriteLine("---------PRACTICO 01--------"); Console.WriteLine("-----------------------------"); Console.WriteLine("-----------------------------"); Console.WriteLine("-OPCIONES-"); Console.WriteLine("1-Registrar Empleado-"); Console.WriteLine("2-Listar Empleados-"); Console.WriteLine("3-Calcular Salario-"); Console.WriteLine("4-Eliminar Empleado-"); Console.WriteLine("5-Salir-"); Console.WriteLine("INGRESE SU OPCION: "); opcion = int.Parse(Console.ReadLine()); while (opcion < 1 || opcion > 5) //control de la variable opcion { Console.WriteLine("Error, opcion no valida"); Console.WriteLine("INGRESE SU OPCION: "); opcion = int.Parse(Console.ReadLine()); } Console.Clear(); switch (opcion) { case 1: try { log.Info("Opcion 1 -Registrar Empleado-"); //Employee empleado; numeradorId++; Console.WriteLine("Nombre:"); nombre = Console.ReadLine(); Console.WriteLine("Es PartTime(P) o FullTime(F):"); tipoEmpleado = char.Parse(Console.ReadLine()); while (tipoEmpleado != 'P' && tipoEmpleado != 'F') //control de la variable opcion { Console.WriteLine("Error, el tipo de empleado no es valido. Ingrese nuevamente (P)o(F)"); tipoEmpleado = char.Parse(Console.ReadLine()); } if (tipoEmpleado == 'P') { Console.WriteLine("Precio por hora:"); precioHora = double.Parse(Console.ReadLine()); PartTimeEmployee empleado = new PartTimeEmployee(); empleado.HourlyRate = precioHora; empleado.Name = nombre; empleado.Id = numeradorId; empleado.StartDate = DateTime.Now; handler.AddEmployee(empleado); } else { Console.WriteLine("Precio mensual:"); salario = int.Parse(Console.ReadLine()); FullTimeEmployee empleado = new FullTimeEmployee(); empleado.Salary = salario; empleado.Name = nombre; empleado.Id = numeradorId; empleado.StartDate = DateTime.Now; handler.AddEmployee(empleado); } Console.WriteLine("Empleado registrado correctamente!"); } catch (Exception e) { log.Error("Error en el registro del empleado:", e); } log.Info("Fin Opcion 1 - Registrar Empleado-"); break; case 2: log.Info("Inicio Opcion 2 - Listar Empleados-"); List <Employee> empleados = handler.GetAllEmployees(); Console.WriteLine("ID NOMBRE FECHA DE INGRESO TIPO"); string tipo; foreach (Employee empleado in empleados) { if (empleado is FullTimeEmployee) { tipo = "FullTime"; } else { tipo = "PartTime"; } Console.WriteLine("{0} {1} {2} {3} ", empleado.Id, empleado.Name, empleado.StartDate, tipo); } log.Info("Fin Opcion 2 - Listar Empleados-"); break; case 3: try { log.Info("Inicio Opcion 3 - Calculo Horas-"); int idCalcular, horas; Console.WriteLine("Ingrese el id del empleado a calcular:"); idCalcular = int.Parse(Console.ReadLine()); Console.WriteLine("Ingrese la cantidad de horas trabajadas:"); horas = int.Parse(Console.ReadLine()); Double salarioCalculado = handler.CalcPartTimeEmployeeSalary(idCalcular, horas); Console.WriteLine("El salario correspondiente es: $ {0}", salarioCalculado); //falta agarrar el throw } catch (Exception e) { log.Error("Error en el calculo:", e); } log.Info(" Fin Opcion 3 - Calculo Horas-"); break; case 4: try { log.Info(" Inicio Opcion 4 - Baja Empleados-"); Console.WriteLine("Ingrese el id del empleado a dar de baja:"); int id = int.Parse(Console.ReadLine()); handler.DeleteEmployee(id); Console.WriteLine("Empleado dado de baja correctamente"); } catch (Exception e) { log.Error("Error en Delete Employee:", e); } log.Info(" Fin Opcion 4 - Baja Empleados-"); break; } } while (opcion != 5); log.Info("Fin del programa"); log.Info("========================================"); }
//private readonly public EmployeeController(IBLEmployees bLEmployees) { this._bLEmployees = bLEmployees; }
static void Main(string[] args) { ILog log = LogManager.GetLogger("Logger"); using (UnityContainer container = new UnityContainer()) { container.LoadConfiguration(); IBLEmployees blHandler = container.Resolve <IBLEmployees>(); Employee e; FullTimeEmployee fte; PartTimeEmployee p; PrintHelp(); System.Console.Write(">"); string line = Console.ReadLine(); log4net.Config.XmlConfigurator.Configure(); do { string[] parameters = line.Split(new string[] { " " }, StringSplitOptions.None); try { switch (parameters[0]) { case "help": PrintHelp(); break; case "AddFullTimeEmployee": fte = new FullTimeEmployee(); foreach (string s in parameters) { System.Console.WriteLine(s); } fte.Name = parameters[1]; fte.StartDate = Convert.ToDateTime(parameters[2]); fte.Salary = Int32.Parse(parameters[3]); blHandler.AddEmployee(fte); break; case "AddPartTimeEmployee": p = new PartTimeEmployee(); p.Name = parameters[1]; p.StartDate = Convert.ToDateTime(parameters[2]); p.HourlyDate = Int32.Parse(parameters[3]); blHandler.AddEmployee(p); break; case "DeleteEmployee": blHandler.DeleteEmployee(Int32.Parse(parameters[1])); break; case "UpdateEmployee": Employee emp = blHandler.GetEmployee(Int32.Parse(parameters[1])); if (emp != null) { emp.Id = Int32.Parse(parameters[1]); emp.Name = parameters[2]; emp.StartDate = Convert.ToDateTime(parameters[3]); int salary = Int32.Parse(parameters[4]); if (emp is FullTimeEmployee) { ((FullTimeEmployee)emp).Salary = salary; } else { ((PartTimeEmployee)emp).HourlyDate = salary; } blHandler.UpdateEmployee(emp); } else { throw new Exception("Error: ID empleado no existe."); } break; case "GetAllEmployees": List <Employee> list = blHandler.GetAllEmployees(); foreach (Employee l in list) { System.Console.WriteLine(l.ToString()); } break; case "GetEmployee": e = blHandler.GetEmployee(Int32.Parse(parameters[1])); System.Console.WriteLine(e.ToString()); break; case "SearchEmployees": list = blHandler.SearchEmployees(parameters[1]); foreach (Employee l in list) { System.Console.WriteLine(l.ToString()); } break; case "CalcPartTime": int id = Int32.Parse(parameters[1]); int hours = Int32.Parse(parameters[2]); double mount = blHandler.CalcPartTimeEmployeeSalary(id, hours); System.Console.WriteLine(mount); break; default: Console.WriteLine("Invalid Command!"); break; } } catch (EmployeeExc exc) { log.Warn(exc.Message, exc); System.Console.WriteLine(exc.Message); } catch (Exception E) { log.Error("Error no controlado:", E); } System.Console.Write(">"); line = System.Console.ReadLine(); } while (!line.Equals("exit")); } }
public EmployeeList() { InitializeComponent(); _IBL = new BLEmployees(new DALEmployeesMock()); }
public Controlador() { IDALEmployees IDALEmp = new DALEmployeesEF(); IB = new BLEmployees(IDALEmp); }