Ejemplo n.º 1
0
        public async Task <IActionResult> AddDepartment(string employeeId)
        {
            var employee = await this.hrEmpService.GetEmployeeByIdAsync(employeeId);

            if (employee == null)
            {
                return(NotFound());
            }

            var departments = await this.GetAllDepartmentsAsync();

            var jobTitles = await this.GetJobTitlesAsync();

            var model = new AddDepartmentAndJobForEmployeeViewModel
            {
                EmployeeId  = employee.Id,
                UserName    = employee.UserName,
                FirstName   = employee.FirstName,
                LastName    = employee.LastName,
                Departments = departments,
                JobTitles   = jobTitles
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddDepartment(AddDepartmentAndJobForEmployeeViewModel model)
        {
            var employee = await this.hrEmpService.GetEmployeeByIdAsync(model.EmployeeId);

            var successedEnrolled = await this.hrEmpService.UpdateEmployeeDepartmentJobTitleAsync(model.EmployeeId, model.DepartmentId, model.JobTitleId);

            if (!successedEnrolled)
            {
                return(BadRequest());
            }

            TempData.AddSuccessMessage($"Employeee {model.UserName} successully added to department and Job");

            return(RedirectToAction(
                       nameof(HRController.Employees),
                       "HR",
                       new { area = $"{AdminConstants.HR_AREA}", page = 1 }));
        }