Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create()
        {
            var viewModel = new JobFunctionEditViewModel
            {
                Departments = await _employeeDetailService.GetDepartments(),
            };

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        public async Task <EmployeeViewModel> GetEmployeeList(EmployeeFilter filter)
        {
            var viewModel = new EmployeeViewModel();

            var employees = await _employeeService.GetAsync(filter);

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

                viewModel.Shifts = await _employeeDetailService.GetShifts();

                viewModel.Positions = await _employeeDetailService.GetPositions();
            }

            return(viewModel);
        }
Ejemplo n.º 4
0
        public async Task <AttendanceFilterModel> GetAttendanceFilterAsync()
        {
            var shifts = await _employeeDetailService.GetShifts();

            var positions = await _employeeDetailService.GetPositions();

            var jobFunctions = await _employeeDetailService.GetJobFunctions();

            var departments = await _employeeDetailService.GetDepartments();

            var sections = await _employeeDetailService.GetSections();

            var filterModel = new AttendanceFilterModel
            {
                Shifts       = shifts,
                Positions    = positions,
                JobFunctions = jobFunctions,
                Departments  = departments,
                Sections     = sections
            };

            return(filterModel);
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
0
        public async Task <ProfileEditViewModel> EditProfile(string employeeId)
        {
            var viewModel = new ProfileEditViewModel();

            viewModel.Departments = await _employeeDetailService.GetDepartments();

            //viewModel.Sections = await _employeeDetailService.GetSections();
            viewModel.Shifts = await _employeeDetailService.GetShifts();

            viewModel.JobTitles = await _employeeDetailService.GetPositions();

            //viewModel.JobFunctions = await _employeeDetailService.GetJobFunctions();
            viewModel.JobLevels = await _employeeDetailService.GetLevels();

            viewModel.BusStations = await _employeeDetailService.GetBusStations();

            var employee = await _employeeService.GetByEmployeeIdAsync(employeeId);

            if (employee != null)
            {
                viewModel.EmployeeId    = employee.EmployeeId;
                viewModel.GlobalId      = employee.GlobalId;
                viewModel.CardId        = employee.CardId;
                viewModel.Title         = employee.Title;
                viewModel.TitleThai     = employee.TitleThai;
                viewModel.EmployeeType  = employee.EmployeeType;
                viewModel.FirstName     = employee.FirstName;
                viewModel.LastName      = employee.LastName;
                viewModel.FirstNameThai = employee.FirstNameThai;
                viewModel.LastNameThai  = employee.LastNameThai;
                viewModel.Gender        = employee.Gender;
                viewModel.BirthDate     = employee.BirthDate;
                viewModel.HireDate      = employee.HireDate;
            }

            var employeeState = await _employeeStateService.GetByEmployeeId(employeeId);

            if (employeeState != null)
            {
                viewModel.DepartmentId  = employeeState.DepartmentId;
                viewModel.SectionId     = employeeState.SectionId;
                viewModel.ShiftId       = employeeState.ShiftId;
                viewModel.JobPositionId = employeeState.PositionId;
                viewModel.JobFunctionId = employeeState.JobFunctionId;
                viewModel.LevelId       = employeeState.LevelId;
                viewModel.BusStationId  = employeeState.BusStationId;
                viewModel.JoinDate      = employeeState.JoinDate;
            }

            var address = await _employeeAddressService.GetByEmployeeId(employeeId);

            if (address != null)
            {
                viewModel.EmployeeAddressId = address.EmployeeAddressId;
                viewModel.HomeAddress       = address.HomeAddress;
                viewModel.City         = address.City;
                viewModel.Country      = address.Country;
                viewModel.PostalCode   = address.PostalCode;
                viewModel.PhoneNumber  = address.PhoneNumber;
                viewModel.EmailAddress = address.EmailAddress;
            }


            return(viewModel);
        }
        public async Task <ProfileEditViewModel> EditProfile(string employeeId)
        {
            var viewModel = new ProfileEditViewModel();

            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();

            var employee = await _employeeService.GetByEmployeeIdWithDetailAsync(employeeId);

            if (employee != null)
            {
                viewModel.EmployeeId    = employee.EmployeeId;
                viewModel.GlobalId      = employee.GlobalId;
                viewModel.CardId        = employee.CardId;
                viewModel.Title         = employee.Title;
                viewModel.TitleThai     = employee.TitleThai;
                viewModel.EmployeeType  = employee.EmployeeType;
                viewModel.FirstName     = employee.FirstName;
                viewModel.LastName      = employee.LastName;
                viewModel.FirstNameThai = employee.FirstNameThai;
                viewModel.LastNameThai  = employee.LastNameThai;
                viewModel.Height        = employee.Height;
                viewModel.Hand          = employee.Hand;
                viewModel.Gender        = employee.Gender;
                viewModel.BirthDate     = employee.BirthDate;
                viewModel.HireType      = employee.HireType;
                viewModel.HireDate      = employee.HireDate;

                if (employee.EmployeeState != null)
                {
                    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;
                }
            }

            var address = await _employeeAddressService.GetByEmployeeId(employeeId);

            if (address != null)
            {
                viewModel.EmployeeAddressId = address.EmployeeAddressId;
                viewModel.HomeAddress       = address.HomeAddress;
                viewModel.City         = address.City;
                viewModel.Country      = address.Country;
                viewModel.PostalCode   = address.PostalCode;
                viewModel.PhoneNumber  = address.PhoneNumber;
                viewModel.EmailAddress = address.EmailAddress;
            }

            var image = await _employeeImageService.GetByEmployeeId(employeeId);

            if (image != null)
            {
                var imageBase64Data = Convert.ToBase64String(image.Images);
                viewModel.ProfileImage = string.Format("data:image/png;base64,{0}", imageBase64Data);
            }

            return(viewModel);
        }