예제 #1
0
        protected override void ExcuteSelf()
        {
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
            {
                _Employee.Account = _IAccountBll.GetAccountById(_Employee.Account.Id);
                if (_Employee.Account != null &&
                    _Employee.Account.Position != null &&
                    _Employee.Account.Position.Description != null)
                {
                    _Employee.EmployeeDetails      = _Employee.EmployeeDetails ?? new EmployeeDetails();
                    _Employee.EmployeeDetails.Work = _Employee.EmployeeDetails.Work ?? new Work();
                    _Employee.EmployeeDetails.Work.Responsibility = _Employee.Account.Position.Description;
                }

                //得到后台帐号
                Account accountOperator = _IAccountBll.GetAccountById(_Operatoraccount.Id);
                _DalEmployee.CreateEmployee(_Employee);
                //新增员工技能
                _DalEmployeeSkill.InsertEmployeeSkill(_Employee);
                //员工福利包括历史的新增
                if (_Employee.EmployeeWelfare != null)
                {
                    SaveEmployeeWelfare SaveEmployeeWelfare =
                        new SaveEmployeeWelfare(_Employee.Account.Id, _Employee.EmployeeWelfare.SocialSecurity.Type,
                                                _Employee.EmployeeWelfare.SocialSecurity.Base,
                                                _Employee.EmployeeWelfare.SocialSecurity.EffectiveYearMonth,
                                                _Employee.EmployeeWelfare.AccumulationFund.Account,
                                                _Employee.EmployeeWelfare.AccumulationFund.EffectiveYearMonth,
                                                _Employee.EmployeeWelfare.AccumulationFund.Base,
                                                accountOperator.Name,
                                                _Employee.EmployeeWelfare.AccumulationFund.SupplyAccount,
                                                _Employee.EmployeeWelfare.AccumulationFund.SupplyBase,
                                                _Employee.EmployeeWelfare.SocialSecurity.YangLaoBase,
                                                _Employee.EmployeeWelfare.SocialSecurity.ShiYeBase,
                                                _Employee.EmployeeWelfare.SocialSecurity.YiLiaoBase,
                                                _DalEmployeeWelfare, _DalEmployeeWelfareHistory);
                    SaveEmployeeWelfare.Excute();
                }

                //员工自定义流程
                if (_Employee.DiyProcessList != null)
                {
                    SaveEmployeeDiyProcess saveProcess =
                        new SaveEmployeeDiyProcess(_Employee.Account.Id, _Employee.DiyProcessList);
                    saveProcess.Excute();
                }
                //员工调休规则
                if (_Employee.AdjustRule != null)
                {
                    new EditEmployeeAdjustRule(_Employee.Account.Id, _Employee.AdjustRule).Excute();
                }
                //记录员工的历史,再次加载信息,为了拍下当时的部门信息(部门名字,部门主管)
                _Employee.Account.Dept = _IDepartmentBll.GetDepartmentById(_Employee.Account.Dept.Id, null);
                //记录员工的历史
                EmployeeHistory employeeHistory =
                    new EmployeeHistory(_Employee, DateTime.Now, accountOperator, "");
                _DalEmployeeHistory.CreateEmployeeHistory(employeeHistory);
                ts.Complete();
            }
        }
예제 #2
0
        public async Task <JsonResult> SaveEmployee(EmployeeModel employeeModel)
        {
            JsonData <JsonStatus> data = new JsonData <JsonStatus>(new JsonStatus());

            if (ModelState.IsValid)
            {
                if (employeeModel.EmployeeId > 0)
                {
                    // update record.
                    if (true == await _employee.UpdateEmployee(employeeModel))
                    {
                        data.Result.Status = true;
                    }
                }
                else
                {
                    // add new record.
                    if (await _employee.CreateEmployee(employeeModel) > 0)
                    {
                        data.Result.Status = true;
                    }
                }
            }

            return(Json(data));
        }
 public int CreateNewEmployee(TblEmployee model)
 {
     try
     {
         return(employee.CreateEmployee(model));
     }
     catch (Exception ex)
     {
         StaticHelper.LogException(path: up.GetLogFilePath(), errorMessage: ex.Message, methodName: $"Class Name: {nameof(EmployeePresenter)} - Method name:  {nameof(CreateNewEmployee)}", stackTrace: ex.StackTrace);
         return(0);
     }
 }
예제 #4
0
        public IActionResult CreateEmployee([FromBody] Employee newobj) //Create New Orchid
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (newobj == null)
            {
                return(BadRequest());
            }
            _employerepo.CreateEmployee(newobj);

            return(NoContent());
        }
예제 #5
0
        public ActionResult Create([FromBody] employeeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var company          = _company.GetCompanyById(model.MCompany.Id);
            var serializeCompany = CompanyMapper.SerializeCompany(company);

            model.MCompany = serializeCompany;
            var serializeEmployee = EmployeeMapper.SerializeEmployee(model);
            var newEmployee       = _employee.CreateEmployee(serializeEmployee);

            return(Ok(newEmployee));
        }
 public HttpResponseMessage PostNewEmployee(Employee employee)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid data!!!"));
         }
         employeeManager.CreateEmployee(employee);
         return(Request.CreateResponse(HttpStatusCode.OK, "Employee created!"));
     }
     catch (Exception e)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error occured while executing PostNewEmployee:" + e.Message));
     }
 }
예제 #7
0
        public async Task <ActionResult <EmployeeDTO> > CreateEmployee(EmployeeDTO employeeDTO)
        {
            await _employee.CreateEmployee(employeeDTO);

            // When we create a new employee, an email is sent to the new employee to welcome them to the company
            string subject     = "Welcome to VROOM!";
            string htmlMessage = $"<h2>Congratulations {employeeDTO.FirstName}!</h2><p> Welcome to the team! We are excited to have you at the {employeeDTO.BranchName}. We know you’re going to be a valuable asset to our company and are looking forward to the positive impact you’re going to have here in your new { employeeDTO.Title } role.</p><p>We are looking forward to your start date of Monday, September 1st. Please arrive by 9:30 a.m. at {employeeDTO.BranchAddress}, and park anywhere in our parking lot. Once you arrive, check in at the reception desk. Your HR representative will meet you in the lobby to set you up with all of your new equipment.</p><p>If you have any questions before Monday, feel free to email or call your office manager at {employeeDTO.BranchPhone}.</p><p> Looking forward to working with you!</p>";

            await _emailSenderService.SendEmailAsync(employeeDTO.Email, subject, htmlMessage);

            // Send the CEO an email to notify them of new employee
            string subject2     = "New Employee Alert";
            string htmlMessage2 = $"<h2>New Employee Alert</h2><p> A new employee was added to the system, please see more details below:</p><h4> Employee Information:</h4><ul><li> First Name: { employeeDTO.FirstName}</li><li> Last Name: { employeeDTO.LastName}</li><li> Email: { employeeDTO.Email}</li><li> Phone: { employeeDTO.Phone}</li><li> Dept: { employeeDTO.Dept}</li><li> Title: { employeeDTO.Title}</li></ul><h4> Branch Information:</h4><ul><li> BranchName: { employeeDTO.BranchName}</li><li> BranchAddress: { employeeDTO.BranchAddress}</li><li> BranchPhone: { employeeDTO.BranchPhone}</li></ul><p> For more details and to update the employee information, please login to your VROOM account.</p> ";

            await _emailSenderService.SendEmailAsync(_config["CorporateEmail"], subject2, htmlMessage2);

            return(CreatedAtAction("GetEmployee", new { id = employeeDTO.Id }, employeeDTO));
        }
예제 #8
0
 //Tạo nhân viên mới
 public void createEmployee(Employee employee)
 {
     employeeDao.CreateEmployee(employee);
     nodeJSServices.addEmployeeToNodejs(employee);
 }
예제 #9
0
        public async void CanGetAnEEItem()
        {
            //Arrange
            var employee01 = await _employee.CreateEmployee(
                new EmployeeDTO
            {
                FirstName     = "FirstName01",
                LastName      = "LastName01",
                Email         = "*****@*****.**",
                Phone         = "555-555-5555",
                Dept          = "Dept01",
                Title         = "Title01",
                StatusId      = (int)EmployeeStatus.Current,
                Status        = (EmployeeStatus.Current).ToString(),
                BranchName    = "Branch01",
                BranchAddress = "Branch Address 01",
                BranchPhone   = "555-555-5555"
            }
                );

            var item01 = await _equipmentItem.Create(
                new EquipmentItemDTO
            {
                Name  = "EquipmentItem01",
                Value = 10.11m
            }
                );

            EmployeeEquipmentItemDTO EEItemDTO = new EmployeeEquipmentItemDTO
            {
                EmployeeId      = employee01.Id,
                EquipmentItemId = item01.Id,
            };
            var EEItemRepo = BuildEEItemRepo();

            //Act
            var EEItem01 = await EEItemRepo.SetEquipmentItemAsBorrowedBy(employee01.Id, EEItemDTO);

            var EEItems = await EEItemRepo.GetAllEmployeeEquipmentRecords();

            //Assert
            Assert.NotNull(EEItem01);
            Assert.Equal(employee01.Id, EEItem01.EmployeeId);
            Assert.Equal(item01.Id, EEItem01.EquipmentItemId);
            Assert.True(EEItems.Count >= 1);
            bool containsTestItem = false;

            foreach (EmployeeEquipmentItemDTO oneEEItemDTO in EEItems)
            {
                if (oneEEItemDTO.EmployeeId == employee01.Id &&
                    oneEEItemDTO.EquipmentItemId == item01.Id &&
                    oneEEItemDTO.StatusId == (int)EmployeeEquipmentStatus.Borrowed)
                {
                    containsTestItem = true;
                }
            }
            Assert.True(containsTestItem);
        }
예제 #10
0
 //Tạo nhân viên mới
 public void createEmployee(Employee employee)
 {
     employeeDao.CreateEmployee(employee);
 }