Exemple #1
0
        private void AddEmployee(object sender)
        {
            sel_emp = new EmployeeModel();
            EmployeeWindow cw = new EmployeeWindow(sel_emp);

            if (cw.ShowDialog() == true)
            {
                db.AddEmployee(sel_emp);
                db.Save();
                SetData();
            }
        }
        public void TestAddEmployee()
        {
            //Arrange
            Employee employee = new Employee();

            employee.employeeID     = 7;
            employee.employeeName   = "Kathy";
            employee.gender         = "F";
            employee.address        = "NYC";
            employee.startDate      = Convert.ToDateTime("2018-10-21");
            employee.departmentID   = 7;
            employee.departmentName = "Acting";
            employee.BasicPay       = 55000;
            //Act
            DBOperations.AddEmployee(employee);
            double actual   = DBOperations.GetSalary("Kathy");
            double expected = 55000;

            //Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        public IHttpActionResult AddEmployee(Employee newEmp)
        {
            if (DBOperations.AddEmployee(newEmp, out string msg))
            {
                if (DBOperations.AddUser(newEmp))
                {
                    if (newEmp.IsManager == "1")
                    {
                        var resultOfAddManagers = StoredProcsCall.AddManagers(newEmp.EmployeeId);
                        if (!resultOfAddManagers)
                        {
                            return(Ok("Unable to add employee to managers table"));
                        }
                    }

                    var resultOfLeaveAllocation = StoredProcsCall.AllocateLeave(newEmp.EmployeeId, newEmp.DOJ.Month);
                    if (!resultOfLeaveAllocation)
                    {
                        return(Ok("Unable to set up leave allocation"));
                    }
                    if (!DBOperations.AddReportingAuthorities(newEmp.EmployeeId, newEmp.managerName))
                    {
                        return(Ok("Unable to set Reporting Authority!"));
                    }
                    CompleteRegistration(newEmp);
                    return(Ok("Associate has been added successfully!"));
                }

                else
                {
                    return(Ok("Failed to add user"));
                }
            }
            else
            {
                return(Ok(msg));
            }
        }