예제 #1
0
        public async Task <IActionResult> ActiveWork(AttendanceFilter filterModel)
        {
            var viewModel = new AttendanceViewModel();

            if (string.IsNullOrEmpty(filterModel.AttendanceDate))
            {
                filterModel.AttendanceDate = DateTime.Today.ToString("yyyy/MM/dd");
            }

            viewModel.Attendances = await _attendanceService.GetActiveAsync(filterModel);

            viewModel.Departments = await _employeeDetailService.GetDepartments();

            viewModel.Shifts = await _employeeDetailService.GetShifts();

            viewModel.Positions = await _employeeDetailService.GetPositions();

            if (filterModel.DepartmentId.HasValue)
            {
                viewModel.Sections = await _employeeDetailService.GetSectionsByDepartmentId(filterModel.DepartmentId.Value);
            }

            if (filterModel.SectionId.HasValue)
            {
                viewModel.JobFunctions = await _employeeDetailService.GetJobFunctionsBySectionId(filterModel.SectionId.Value);
            }

            _httpContextAccessor.HttpContext.Session.SetObjectAsJson("attendances", viewModel.Attendances);

            return(View(viewModel));
        }
        public async Task <EmployeeInfoViewModel> GetEmployeeInfo(string employeeId)
        {
            var viewModel = new EmployeeInfoViewModel();

            var employee = await _employeeService.GetByEmployeeIdWithDetailAsync(employeeId);

            if (employee != null)
            {
                viewModel.Departments = await _employeeDetailService.GetDepartments();

                viewModel.Shifts = await _employeeDetailService.GetShifts();

                viewModel.JobPosition = await _employeeDetailService.GetPositions();

                viewModel.JobLevels = await _employeeDetailService.GetLevels();

                viewModel.Routes = await _employeeDetailService.GetRoutes();

                //viewModel.BusStations = await _employeeDetailService.GetBusStations();

                if (employee.EmployeeState != null)
                {
                    viewModel.EmployeeId    = employee.EmployeeState.EmployeeId;
                    viewModel.DepartmentId  = employee.EmployeeState.JobFunction.Section.Department.DepartmentId;
                    viewModel.SectionId     = employee.EmployeeState.JobFunction.Section.SectionId;
                    viewModel.ShiftId       = employee.EmployeeState.ShiftId;
                    viewModel.JobPositionId = employee.EmployeeState.PositionId;
                    viewModel.JobFunctionId = employee.EmployeeState.JobFunctionId;
                    viewModel.LevelId       = employee.EmployeeState.LevelId;
                    viewModel.RouteId       = employee.EmployeeState.BusStation.Route.RouteId;
                    viewModel.BusStationId  = employee.EmployeeState.BusStationId;
                    viewModel.JoinDate      = employee.EmployeeState.JoinDate;

                    viewModel.Sections = await _employeeDetailService.GetSectionsByDepartmentId(viewModel.DepartmentId);

                    viewModel.JobFunctions = await _employeeDetailService.GetJobFunctionsBySectionId(viewModel.SectionId);

                    viewModel.BusStations = await _employeeDetailService.GetGetBusStationsByRouteId(viewModel.RouteId);
                }

                var profileHeader = new ProfileHeaderViewModel()
                {
                    FullName     = $"{employee.Title}.{employee.FirstName} {employee.LastName}",
                    FullNameThai = $"{employee.TitleThai}.{employee.FirstNameThai} {employee.LastNameThai}",
                    ProfileImage = await GetProfileImage(employeeId)
                };

                viewModel.ProfileHeader = profileHeader;
            }

            return(viewModel);
        }
예제 #3
0
        public async Task <IActionResult> EmployeeList(EmployeeFilter filterModel)
        {
            var viewModel = new EmployeeViewModel();

            viewModel.Departments = await _employeeDetailService.GetDepartments();

            viewModel.Shifts = await _employeeDetailService.GetShifts();

            viewModel.Positions = await _employeeDetailService.GetPositions();

            viewModel.JobLevels = await _employeeDetailService.GetLevels();

            if (filterModel.AvailableFlag == null)
            {
                filterModel.AvailableFlag = true;
            }

            if (filterModel.DepartmentId.HasValue)
            {
                viewModel.Sections = await _employeeDetailService.GetSectionsByDepartmentId(filterModel.DepartmentId.Value);
            }

            if (filterModel.SectionId.HasValue)
            {
                viewModel.JobFunctions = await _employeeDetailService.GetJobFunctionsBySectionId(filterModel.SectionId.Value);
            }

            var employees = await _employeeService.GetAsync(filterModel);

            if (employees != null)
            {
                viewModel.Employees = employees;
            }

            return(View(viewModel));
        }
예제 #4
0
 public async Task <IEnumerable <SelectListItem> > GetJobFunctionBySectionId(int sectionId)
 {
     return(await _employeeDetailService.GetJobFunctionsBySectionId(sectionId));
 }