コード例 #1
0
        public ActionResult Create()
        {
            MXTimer timing = new MXTimer();

            EmployeeViewModel model = new EmployeeViewModel();

            //let's go parallel
            Task[] tasks = new Task[2];

            tasks[0] = Task.Factory.StartNew(
                    () =>
                        model.LstGender = _repository.GetOptionSet<Gender, DenormalizedReference>()
                    );

            tasks[1] = Task.Factory.StartNew(
                    () =>
                        model.LstRating = _repository.GetOptionSet<ProgrammingRating, DenormalizedReference>()
                    );

            model.LstSkill = _repository.GetOptionSet<Skill, DenormalizedReference>().Select(c => new MXCheckBoxItem { DenormalizedReference = c }).ToList();

            Task.WaitAll(tasks);

            ViewBag.QueryTime = timing.Finish();

            return View(model);
        }
コード例 #2
0
        public ActionResult Create(EmployeeViewModel model)
        {
            model.Employee.Gender = _repository.GetOptionById<Gender, DenormalizedReference>(model.Employee.Gender.DenormalizedId);
            model.Employee.ProgrammingRating = _repository.GetOptionById<ProgrammingRating, DenormalizedReference>(model.Employee.ProgrammingRating.DenormalizedId);

            model.Employee.Skills = model.LstSkill.Where(c => c.IsSelected == true).Select(c => c.DenormalizedReference).ToList();

            _repository.Insert<Employee>(model.Employee);
                       
            return RedirectToAction("Index");
        }
コード例 #3
0
        public ActionResult Edit(string id)//employeeId
        {
            MXTimer timing = new MXTimer();

            EmployeeViewModel model = new EmployeeViewModel
            {
                Employee = _repository.GetOne<Employee>(id),
            };

            //let's go parallel
            Task[] tasks = new Task[2];

            tasks[0] = Task.Factory.StartNew(
                    () =>
                        model.LstGender = _repository.GetOptionSet<Gender, DenormalizedReference>()
                    );

            tasks[1] = Task.Factory.StartNew(
                    () =>
                        model.LstRating = _repository.GetOptionSet<ProgrammingRating, DenormalizedReference>()
                    );

            model.LstSkill = _repository.GetOptionSet<Skill, DenormalizedReference>().Select(c => new MXCheckBoxItem { DenormalizedReference = c }).ToList();

            foreach (var item in model.LstSkill)
            {
                if (model.Employee.Skills != null && model.Employee.Skills.Select(c => c.DenormalizedId).Contains(item.DenormalizedReference.DenormalizedId)) 
                    item.IsSelected = true;
            }

            Task.WaitAll(tasks);

            ViewBag.QueryTime = timing.Finish();

            return View(model);
        }