コード例 #1
0
        public ActionResult Index()
        {
            var model = new SearchParamViewModel
            {
                StartDate = DateTime.Now + TimeSpan.FromDays(1),
                EndDate = DateTime.Now + TimeSpan.FromDays(90),
            };

            IEnumerable<CustomerInfo> customers = this.customerService.GetCustomers();

            ViewData["Customers"] = new SelectList(customers, "Id", "Name");
            ViewData["Skills"] = GetSkillSelectList(model.SelectedSkills);
            ViewData["CareerLevels"] = GetCareerLevelsSelectList(model.SelectedCareerLevels);

            return View(model);
        }
コード例 #2
0
        public ActionResult Result(SearchParamViewModel searchParams)
        {
            if (!ModelState.IsValid)
            {
                IEnumerable<CustomerInfo> customers = this.customerService.GetCustomers();

                // send back search-view with validation errors.
                ViewData["Customers"] = new SelectList(customers, "Id", "Name");
                ViewData["Skills"] = GetSkillSelectList(searchParams.SelectedSkills);
                ViewData["CareerLevels"] = GetCareerLevelsSelectList(searchParams.SelectedCareerLevels);
                return View("Index", searchParams);
            }

            IEnumerable<EmployeeSearchResult> employees = SearchEmployees(searchParams);
            IEnumerable<EmployeeIdentifierViewModel> employeeIdentifiers = employees.Select(
                e => new EmployeeIdentifierViewModel
                {
                    EmployeeId = e.Id,
                    EmployeeName = e.EmployeeName
                });

            ViewData["SearchParamViewModel"] = searchParams;
            return View("Result", employeeIdentifiers);
        }
コード例 #3
0
        private IEnumerable<EmployeeSearchResult> SearchEmployees(SearchParamViewModel searchParamViewModel)
        {
            var query = new EmployeeQuery
            {
                BeginOfWorkPeriod = searchParamViewModel.StartDate,
                EndOfWorkPeriod = searchParamViewModel.EndDate,
                CustomerId = searchParamViewModel.SelectedCustomer,
                RequestedCareerLevels = searchParamViewModel.SelectedCareerLevels.Select(i => (CareerLevel)i).ToArray(),
                RequestedSkills = searchParamViewModel.SelectedSkills.Select(i => (Skill)i).ToArray()
            };

            return this.reservationService.FindPotentialEmployeesForCustomer(query);
        }