Beispiel #1
0
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         if (collection["Type"] == "1")
         {
             PartTimeEmployee emp = new PartTimeEmployee();
             emp.Id         = id;
             emp.Name       = collection["Name"];
             emp.StartDate  = DateTime.Parse(collection["StartDate"]);
             emp.HourlyRate = Convert.ToDouble(collection["Salary"]);
             _bl.UpdateEmployee(emp);
         }
         else
         {
             if (collection["Type"] == "2")
             {
                 FullTimeEmployee emp = new FullTimeEmployee();
                 emp.Id        = id;
                 emp.Name      = collection["Name"];
                 emp.StartDate = DateTime.Parse(collection["StartDate"]);
                 emp.Salary    = Convert.ToInt32(collection["Salary"]);
                 _bl.UpdateEmployee(emp);
             }
         }
         return(RedirectToAction("Index"));
     }
     catch {
         return(View());
     }
 }
 // PUT api/<controller>/5
 public void Put(int id, [FromBody] Shared.Entities.ApiEmployee emp)
 {
     Shared.Entities.Employee empleado = _bl.GetEmployee(id);
     if (empleado.GetType() == typeof(Shared.Entities.FullTimeEmployee))
     {
         Shared.Entities.FullTimeEmployee e = new Shared.Entities.FullTimeEmployee();
         e.Id        = empleado.Id;
         e.Name      = emp.Name;
         e.StartDate = emp.StartDate;
         e.Salary    = emp.Salary;
         _bl.UpdateEmployee(e);
     }
     else
     {
         if (empleado.GetType() == typeof(Shared.Entities.PartTimeEmployee))
         {
             Shared.Entities.PartTimeEmployee e = new Shared.Entities.PartTimeEmployee();
             e.Id         = empleado.Id;
             e.Name       = emp.Name;
             e.StartDate  = emp.StartDate;
             e.HourlyRate = emp.Salary;
             _bl.UpdateEmployee(e);
         }
     }
 }
Beispiel #3
0
 private void Guardar_Click(object sender, EventArgs e)
 {
     if (this.Cedula != null && this.Nombre != null && FechaIng != null)
     {
         if (this.isPartTime.Checked = true && this.IsFullTime.Checked != true)
         {
             PartTimeEmployee nuevo = new PartTimeEmployee();
             nuevo.Id         = int.Parse(this.Cedula.Text);
             nuevo.Name       = this.Nombre.Text;
             nuevo.StartDate  = this.FechaIng.Value;
             nuevo.SalXHora   = int.Parse(Salario.Text);
             nuevo.HourlyRate = int.Parse(CantHoras.Text);
             if (edit)
             {
                 _IBL.UpdateEmployee(nuevo);
             }
             else
             {
                 _IBL.AddEmployee(nuevo);
             }
             this.Cedula.Text        = "";
             this.Nombre.Text        = "";
             this.Salario.Text       = "";
             this.CantHoras.Text     = "";
             this.isPartTime.Checked = false;
         }
         else
         {
             if (this.isPartTime.Checked != true && this.IsFullTime.Checked == true)
             {
                 FullTimeEmployee nuevo = new FullTimeEmployee();
                 nuevo.Id        = int.Parse(this.Cedula.Text);
                 nuevo.Name      = this.Nombre.Text;
                 nuevo.StartDate = this.FechaIng.Value;
                 nuevo.Salary    = int.Parse(Salario.Text);
                 if (edit)
                 {
                     _IBL.UpdateEmployee(nuevo);
                 }
                 else
                 {
                     _IBL.AddEmployee(nuevo);
                 }
                 this.Cedula.Text        = "";
                 this.Nombre.Text        = "";
                 this.Salario.Text       = "";
                 this.CantHoras.Text     = "";
                 this.IsFullTime.Checked = false;
             }
         }
     }
 }
Beispiel #4
0
 public void UpdateEmployee(Employee emp)
 {
     try
     {
         blHandler.UpdateEmployee(emp);
     }
     catch
     {
         throw new Exception("Problemas al updatear empleado de id: " + emp.Id);
     }
     //throw new NotImplementedException();
 }
Beispiel #5
0
 public void UpdateEmployee(Employee emp)
 {
     blHandler.UpdateEmployee(emp);
 }
 public void UpdateEmployee(Shared.Entities.Employee e)
 {
     _bl.UpdateEmployee(e);
 }
 public void UpdateEmployee(Employee emp)
 {
     //throw new NotImplementedException();
     blHandler.UpdateEmployee(emp);
 }
Beispiel #8
0
        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"));
            }
        }
Beispiel #9
0
 public void UpdateEmployee(Employee emp)
 {
     IB.UpdateEmployee(emp);
 }