Exemplo n.º 1
0
        public ActionResult Manager(string employeeTC)
        {
            employeeTC = employeeTC.ToUpper();
            var model = EmployeeVMService.GetEmployee(employeeTC);

            if (model == null || model.Employee.IsTrainer)
            {
                return(Redirect(SimplePages.FullUrls.Trainers));
            }

            return(MView(ViewNames.Details, model));
        }
        /// <summary>
        /// 根据用户 Id 返回员工视图模型
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <EmployeeVM> GetEmployeeVMByUserId(Guid id)
        {
            EmployeeVM employeeVM        = null;
            var        employeeService   = new EmployeeVMService(_employeeRepository, _studentRepository, _gradeAndClassRepository, _departmentRepository, _businessImageRepository, _jobTitleRepository, _userManager, _roleManager);
            var        employeeUserItems = await _employeeRepository.GetAllIncludingAsyn(x => x.User);

            var employeeUser = employeeUserItems.Where(x => x.User != null).FirstOrDefault(x => x.User.Id == id);

            if (employeeUser != null)
            {
                employeeVM = employeeService.GetVM(employeeUser.Id);
            }
            return(employeeVM);
        }
        /// <summary>
        /// 根据用户 Id 更新地址
        /// </summary>
        /// <param name="id"></param>
        /// <param name="valString"></param>
        /// <returns></returns>
        public async Task <IActionResult> EditPersonAddress(Guid id, string valString)
        {
            var updateStatus = true;
            // 更新用户相关的
            var employeeService = new EmployeeVMService(_employeeRepository, _studentRepository, _gradeAndClassRepository, _departmentRepository, _businessImageRepository, _jobTitleRepository, _userManager, _roleManager);
            var employeeVM      = await _boVMService.GetEmployeeVMByUserId(id);

            if (employeeVM != null)
            {
                employeeVM.Address = valString;
                updateStatus       = await employeeService.SaveBo(employeeVM);
            }

            return(Json(updateStatus));
        }
Exemplo n.º 4
0
        public ActionResult Trainer(string employeeTC)
        {
            if (employeeTC.IsEmpty())
            {
                return(ErrorView(HttpStatusCode.NotFound));
            }

            employeeTC = employeeTC.ToUpper();
            var model = EmployeeVMService.GetEmployee(employeeTC);

            if (model == null)
            {
                return(NotFound());
            }
            return(View(ViewNames.Details, model));
        }
Exemplo n.º 5
0
        private void InitModel(UserFileVM model)
        {
            var employeeTC = User.Employee_TC;
            var week       = DateTime.Today.AddDays(14);
            var pastWeek   = DateTime.Today.AddDays(-14);
            var groups     = EmployeeVMService.GetTrainerGroups(employeeTC)
                             .Where(x => x.LectureType_TC != LectureTypes.OpenLearning)
                             .Where(x =>
                                    (pastWeek <= x.DateBeg && x.DateBeg <= week) ||
                                    (pastWeek <= x.DateEnd && x.DateEnd <= week)).ToList()
                             .OrderBy(x => x.DateBeg).ToList();
            var courses = EmployeeVMService.GetCourses().CourseHasVideos.Select(x => x.Item1).ToList();

            model.Groups  = groups;
            model.Courses = courses;
        }
        public EmployeeController(
            IEntityRepository <Employee> repository,
            IEntityRepository <Student> studentpository,
            IEntityRepository <GradeAndClass> gradeRepository,
            IEntityRepository <Department> departmentRepository,
            IEntityRepository <BusinessImage> imageRepository,
            IEntityRepository <JobTitle> jobTitleRepository,
            UserManager <ApplicationUser> userManager,
            RoleManager <ApplicationRole> roleManager
            )
        {
            _boRepository         = repository;
            _studentpository      = studentpository;
            _departmentRepository = departmentRepository;
            _gradeRepository      = gradeRepository;
            _imageRepository      = imageRepository;
            _jobTitleRepository   = jobTitleRepository;
            _roleManager          = roleManager;
            _userManager          = userManager;

            _boVMService = new EmployeeVMService(_boRepository, _studentpository, _gradeRepository, _departmentRepository, _imageRepository, _jobTitleRepository, _userManager, _roleManager);
        }
Exemplo n.º 7
0
 public ActionResult Courses()
 {
     return(View(EmployeeVMService.GetCourses()));
 }
Exemplo n.º 8
0
 public ActionResult Groups()
 {
     return(View(EmployeeVMService.GetGroups()));
 }
Exemplo n.º 9
0
        public ActionResult AboutTrainer(string employeeTC, string urlName, int?pageIndex)
        {
            if (employeeTC.IsEmpty())
            {
                return(NotFound());
            }
            if (!pageIndex.HasValue &&
                urlName.In(
                    SimplePages.Urls.TrainerOrgResponses,
                    SimplePages.Urls.TrainerResponses,
                    SimplePages.Urls.TrainerTests,
                    SimplePages.Urls.TrainerAdvices,
                    SimplePages.Urls.TrainerWorks,
                    SimplePages.Urls.TrainerVideos))
            {
                return(RedirectToAction(() => AboutTrainer(employeeTC, urlName, 1)));
            }
            var index = pageIndex.GetValueOrDefault() - 1;

            var model = new AboutTrainerVM();

            model.UrlName  = urlName;
            model.Page     = GetAboutTrainer();
            employeeTC     = employeeTC.ToUpper();
            model.Employee = EmployeeVMService.GetEmployee(employeeTC);
            if (model.Employee == null || !model.Employee.Employee.IsTrainer)
            {
                return(Redirect(SimplePages.FullUrls.Trainers));
            }
            var orgResponses = OrgResponseService.GetAll().IsActive()
                               .Where(r => ("," + r.Employee_TC + ",").Contains("," + employeeTC + ","))
                               .OrderByDescending(o => o.UpdateDate);
            var responses = ResponseService.GetAllForEmployee(employeeTC)
                            .OrderByDescending(x => x.Course.IsActive)
                            .ThenByDescending(o => o.Rating).ThenByDescending(x => x.UpdateDate);

            var advices = AdviceService.GetAll().IsActive()
                          .Where(r => r.Employee_TC == employeeTC)
                          .OrderByDescending(o => o.UpdateDate);
            var tests = TestService.GetAll().Where(x => x.Status == TestStatus.Active)
                        .Where(r => r.Author_TC == employeeTC)
                        .OrderByDescending(o => o.Id);
            var videos = VideoService.GetAll().IsActive()
                         .Where(r => r.Employee_TC == employeeTC)
                         .OrderByDescending(o => o.VideoID);
            var userWorks = UserWorkService.GetAll().IsActive()
                            .Where(r => r.Trainer_TC == employeeTC)
                            .OrderByDescending(o => o.UserWorkID);

            model.HasOrgResponses = orgResponses.Any();
            model.HasResponses    = responses.Any();
            model.HasAdvices      = advices.Any();
            model.HasTests        = tests.Any();
            model.HasVideos       = videos.Any();
            model.HasPortfolio    = Images.GetGallaryFiles(model.Employee.Employee, "Portfolio").Any();
            model.HasWorks        = userWorks.Any();

            if (model.IsTrainerResponses)
            {
                model.Responses = responses.ToPagedList(index, 20);
            }

            if (model.IsTrainerOrgResponses)
            {
                model.OrgResponses = orgResponses.ToPagedList(index, 10);;
            }

            if (model.IsAdvices)
            {
                model.Advices = advices.ToPagedList(index, 10);
            }
            if (model.IsTests)
            {
                model.Tests = tests.ToPagedList(index, 10);
            }
            if (model.IsVideos)
            {
                model.Videos = videos.ToList();
            }
            if (model.IsWorks)
            {
                model.UserWorks = userWorks.ToPagedList(index, 10);
            }
            if (model.IsAboutTrainer)
            {
                model.Certifications = EmployeeCertificationService.GetAll(
                    x => x.EmployeeFK_TC == employeeTC && x.Certification.IsActive)
                                       .OrderBy(x => x.SortOrder)
                                       .Select(x => x.Certification).ToList();
            }
            return(View(model));
        }