public HttpResponseMessage Post(Shared.Entities.EmployeeAPIRest emp) { try { if (emp.TypeEmp == "FullTime") { Shared.Entities.FullTimeEmployee empleado = new Shared.Entities.FullTimeEmployee() { Name = emp.Name, StartDate = Convert.ToDateTime(emp.StartDate), Salary = emp.Salary }; blHandler.AddEmployee(empleado); } else if (emp.TypeEmp == "PartTime") { Shared.Entities.PartTimeEmployee empleado = new Shared.Entities.PartTimeEmployee() { Name = emp.Name, StartDate = Convert.ToDateTime(emp.StartDate), HourlyRate = emp.HourlyRate }; blHandler.AddEmployee(empleado); } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Tipo de usuario incorrecto")); } return(Request.CreateResponse(HttpStatusCode.OK, "Usuario creado correctamente")); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, e)); } }
private void Button2_Click(object sender, EventArgs e) { DataAccessLayer.DALEmployeesEF en = new DataAccessLayer.DALEmployeesEF(); BusinessLogicLayer.BLEmployees bus = new BusinessLogicLayer.BLEmployees(en); if (comboBox1.Text == "FullTimeEmployee") { Shared.Entities.FullTimeEmployee fte = new Shared.Entities.FullTimeEmployee() { Name = textBox1.Text, StartDate = dateTimePicker1.Value, Salary = Int32.Parse(textBox2.Text) }; bus.AddEmployee(fte); } else { Shared.Entities.PartTimeEmployee fte = new Shared.Entities.PartTimeEmployee() { Name = textBox1.Text, StartDate = dateTimePicker1.Value, HourlyRate = Int32.Parse(textBox3.Text) }; bus.AddEmployee(fte); } this.Close(); }
private void Button2_Click(object sender, EventArgs e) { DataAccessLayer.DALEmployeesEF dalef = new DataAccessLayer.DALEmployeesEF(); BusinessLogicLayer.BLEmployees bl = new BusinessLogicLayer.BLEmployees(dalef); if (textBox3.Text == "FullTime") { Shared.Entities.FullTimeEmployee empFT = new Shared.Entities.FullTimeEmployee() { Name = textBox1.Text, StartDate = Convert.ToDateTime(textBox5.Text), Salary = Convert.ToInt32(textBox4.Text) }; bl.AddEmployee(empFT); } else if (textBox3.Text == "PartTime") { Shared.Entities.PartTimeEmployee empPT = new Shared.Entities.PartTimeEmployee() { Name = textBox1.Text, StartDate = Convert.ToDateTime(textBox5.Text), HourlyRate = Convert.ToDouble(textBox3.Text) }; bl.AddEmployee(empPT); } }