public IHttpActionResult addEmployee([FromBody] Employee_Data data)
        {
            if (data == null)
            {
                //Bad request code 400
                return(BadRequest());
            }

            /*
             * if (employeeLogic.existEmployee(data.id))
             * {
             *  //petición correcta pero no pudo ser procesada porque ya existe el archivo code 202
             *  return StatusCode(HttpStatusCode.Accepted);
             * }
             */
            if (employeeLogic.addEmployee(data))
            {
                //petición correcta y se ha creado un nuevo recurso code 201
                return(StatusCode(HttpStatusCode.Created));
            }
            else
            {
                //No se pudo crear el recurso por un error interno code 500
                return(InternalServerError());
            }
        }
        public Employee_Data GetEmployee(int ID)
        {
            Employee_Data employee = new Employee_Data();

            using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
            {
                try
                {
                    if (!this.existEmployee(ID))
                    {
                        employee = null;
                        return(employee);
                    }
                    var emp = construyeEntities.Employees.Find(ID);
                    employee.id             = emp.id;
                    employee.identification = emp.identification;
                    employee.name           = emp.name;
                    employee.lastname1      = emp.lastname1;
                    employee.lastname2      = emp.lastname2;
                    employee.phone          = emp.phone;
                    employee.hour_cost      = emp.hour_cost;
                    return(employee);
                }
                catch (Exception E)
                {
                    employee = null;
                    return(employee);
                }
            }
        }
        public Exception UpdateEmployee(int id, employees employee)
        {
            Employee_Data obj = new Employee_Data(_connection);
            Exception     ex  = obj.UpdateEmployee(id, employee);

            return(ex);
        }
Beispiel #4
0
        [Test] // #16
        public void p()
        {      //@ Add a deparment and check if he existing
            Employee_Data ed = new Employee_Data();

            ed.Remove("14");
            Assert.IsTrue(!ed.Contains("14"));
        }
        public void DeleteEmployee(int id)
        {
            Employee_Data obj = new Employee_Data(_connection);

            obj.DeleteEmployee(id);
            return;
        }
        public Exception SaveEmployee(employees employee)
        {
            Employee_Data obj = new Employee_Data(_connection);
            Exception     ex  = obj.SaveEmployee(employee);

            return(ex);
        }
Beispiel #7
0
        [Test] // #15
        public void o()
        {      //@ Add a worker and check if he existing
            Employee_Data ed = new Employee_Data();

            Backend.Employee c = new Backend.Employee("14", "adam", "bon", "Man", "3434", 20000.0, "0", "Worker");
            ed.Add(c);
            Assert.IsTrue(ed.Contains("14"));
        }
Beispiel #8
0
        public Main()
        {
            InitializeComponent();
            EmartDataContext emartDataContext = new EmartDataContext();
            //data classes of the enities

            List <DAL.User> userSqlDB = (from s in emartDataContext.Users select s).ToList();


            List <Backend.User> userDB    = Change.UserDalToBackendList(userSqlDB);
            User_Data           user_data = new User_Data(userDB);


            List <DAL.Customer> clubMemberSqlDB = (from s in emartDataContext.Customers select s).ToList();
            List <Club_Member>  clubMemberDB    = Change.CustomerDalToBackendList(clubMemberSqlDB);
            ClubMember_Data     clubMember_data = new ClubMember_Data(clubMemberDB);


            List <DAL.Department>     departmentSqlDB = (from s in emartDataContext.Departments select s).ToList();
            List <Backend.Department> departmentDB    = Change.DepartmentDalToBackendList(departmentSqlDB);
            Department_Data           department_data = new Department_Data(departmentDB);

            List <DAL.Employee>     EmployeeSqlDB = (from s in emartDataContext.Employees select s).ToList();
            List <Backend.Employee> EmployeeDB    = Change.EmployeeDalToBackendList(EmployeeSqlDB);
            Employee_Data           employee_data = new Employee_Data(EmployeeDB);


            List <DAL.Product>     productSqlDB = (from s in emartDataContext.Products select s).ToList();
            List <Backend.Product> productDB    = Change.ProductDalToBackendList(productSqlDB);
            Product_Data           product_data = new Product_Data(productDB);

            List <DAL.Transaction>     transactionSqlDB = (from s in emartDataContext.Transactions select s).ToList();
            List <Backend.Transaction> transactionDB    = Change.TransactionDalToBackendList(transactionSqlDB);
            List <DAL.Recipt>          reciptSqlDB      = (from s in emartDataContext.Recipts select s).ToList();
            List <Backend.Receipt>     reciptDB         = Change.ReciptDalToBackendList(reciptSqlDB);
            Transaction_Data           transaction_data = new Transaction_Data(transactionDB, reciptDB);

            Location_Data location_data = new Location_Data();
            // managers
            DAL_Manager dal_manager = new DAL_Manager(user_data, clubMember_data, department_data, employee_data, product_data, transaction_data, location_data);
            BL_Manager  BL_manager  = new BL_Manager(dal_manager);

            Window mw = new MainWindow(BL_manager);

            mw.Show();
            this.Close();
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter name: ");
            string nameFirst = Console.ReadLine();

            Console.WriteLine("Enter day of birth: ");
            int dayFirst = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter month of birth: ");
            int monthFirst = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter year of birth: ");
            int    yearFirst        = int.Parse(Console.ReadLine());
            string dateOfBirthFirst = dayFirst.ToString() + "-" + monthFirst.ToString() + "-" + yearFirst.ToString();

            Console.WriteLine("Enter name: ");
            string nameSecond = Console.ReadLine();

            Console.WriteLine("Enter day of birth: ");
            int daySecond = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter month of birth: ");
            int monthSecond = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter year of birth: ");
            int    yearSecond        = int.Parse(Console.ReadLine());
            string dateOfBirthSecond = daySecond.ToString() + "-" + monthSecond.ToString() + "-" + yearSecond.ToString();

            Employee_Data employeeFirst = new Employee_Data();

            Employee_Data.Name employeeFirstName        = new Employee_Data.Name(nameFirst);
            Employee_Data.Name employeeDateOfBirthFirst = new Employee_Data.Name(dateOfBirthFirst);

            Employee_Data employeeSecond = new Employee_Data();

            Employee_Data.Name employeeSecondName        = new Employee_Data.Name(nameSecond);
            Employee_Data.Name employeeDateOfBirthSecond = new Employee_Data.Name(dateOfBirthSecond);
            employeeFirst.show();
            employeeSecond.show();

            Console.ReadLine();
        }
        public IHttpActionResult GetEmployee(int id)
        {
            if (!employeeLogic.existEmployee(id))
            {
                //No se encontró el recurso code 404
                return(NotFound());
            }
            Employee_Data employee = employeeLogic.GetEmployee(id);

            if (employee != null)
            {
                // ok code 200
                return(Ok(employee));
            }
            else
            {
                //No se pudo crear el recurso por un error interno code 500
                return(InternalServerError());
            }
        }
        public List <Object> GetListEmployee()
        {
            List <Object> dataList = new List <object>();

            using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
            {
                try
                {
                    var employeeList = construyeEntities.Employees.ToList();
                    int n            = employeeList.Count;
                    if (n == 0)
                    {
                        dataList = null;
                        return(dataList);
                    }
                    else
                    {
                        for (int i = 0; i < employeeList.Count; ++i)
                        {
                            Employee_Data data = new Employee_Data();
                            data.id             = employeeList.ElementAt(i).id;
                            data.identification = employeeList.ElementAt(i).identification;
                            data.name           = employeeList.ElementAt(i).name;
                            data.lastname1      = employeeList.ElementAt(i).lastname1;
                            data.lastname2      = employeeList.ElementAt(i).lastname2;
                            data.phone          = employeeList.ElementAt(i).phone;
                            data.hour_cost      = employeeList.ElementAt(i).hour_cost;
                            dataList.Add(data);
                        }
                        return(dataList);
                    }
                }
                catch
                {
                    dataList = null;
                    return(dataList);
                }
            }
        }
        public List <Object> GetAllProjectManagers()
        {
            List <Object> dataList = new List <object>();

            using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
            {
                try
                {
                    var employeeList = construyeEntities.usp_posible_manager().ToList();
                    int n            = employeeList.Count;
                    if (n == 0)
                    {
                        dataList = null;
                        return(dataList);
                    }
                    else
                    {
                        for (int i = 0; i < employeeList.Count; ++i)
                        {
                            Employee_Data data = new Employee_Data();
                            data.id             = employeeList.ElementAt(i).Id_Employee;
                            data.identification = employeeList.ElementAt(i).Identification;
                            data.name           = employeeList.ElementAt(i).Name;
                            data.lastname1      = employeeList.ElementAt(i).Lastname1;
                            data.lastname2      = employeeList.ElementAt(i).Lastname2;
                            data.phone          = employeeList.ElementAt(i).Phone;
                            data.hour_cost      = employeeList.ElementAt(i).hour_cost;
                            dataList.Add(data);
                        }
                        return(dataList);
                    }
                }
                catch
                {
                    dataList = null;
                    return(dataList);
                }
            }
        }
 public bool updateEmployee(Employee_Data data)
 {
     using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
     {
         try
         {
             var employee = construyeEntities.Employees.Find(data.id);
             employee.id             = data.id;
             employee.identification = data.identification;
             employee.name           = data.name;
             employee.lastname1      = data.lastname1;
             employee.lastname2      = data.lastname2;
             employee.phone          = data.phone;
             employee.hour_cost      = data.hour_cost;
             construyeEntities.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
 public IHttpActionResult updateEmployee([FromBody] Employee_Data data)
 {
     if (data == null)
     {
         //Bad request code 400
         return(BadRequest());
     }
     if (!employeeLogic.existEmployee(data.id))
     {
         //petición correcta pero no pudo ser procesada porque no existe el archivo code 404
         return(NotFound());
     }
     if (employeeLogic.updateEmployee(data))
     {
         //petición correcta y se ha creado un nuevo recurso code 200 ok
         return(Ok());
     }
     else
     {
         //No se pudo crear el recurso por un error  code 500
         return(InternalServerError());
     }
 }
 public bool addEmployee(Employee_Data data)
 {
     using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
     {
         Employee newEmployee = new Employee();
         newEmployee.id             = data.id;
         newEmployee.identification = data.identification;
         newEmployee.name           = data.name;
         newEmployee.lastname1      = data.lastname1;
         newEmployee.lastname2      = data.lastname2;
         newEmployee.phone          = data.phone;
         newEmployee.hour_cost      = data.hour_cost;
         try
         {
             construyeEntities.Employees.Add(newEmployee);
             construyeEntities.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Beispiel #16
0
        public IEnumerable <employees> ListaEmployee()
        {
            Employee_Data obj = new Employee_Data(_connection);

            return(obj.ListaEmployee());
        }
Beispiel #17
0
        public employees RetornaEmployee(int id)
        {
            Employee_Data obj = new Employee_Data(_connection);

            return(obj.RetornaEmployee(id));
        }
Beispiel #18
0
 public Employee_BL(Employee_Data dl)
 {
     itsDAL = dl;
 }