public async Task <IActionResult> Create() { var viewModel = new BusStationEditViewModel { Routes = await _employeeDetailService.GetRoutes() }; return(View(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); }