Esempio n. 1
0
        private EvaluationViewModel GenerateEvaluationViewModel(Evaluation evaluation)
        {
            EvaluationViewModel evaluationViewModel = new EvaluationViewModel
            {
                Id             = evaluation.Id,
                EvaluationName = evaluation.EvaluationName,
                FormName       = evaluation.FormName,
                IsCompleted    = evaluation.IsCompleted,
                Sections       = evaluation.Sections,
                Employee       = employeesService.GetEmployeeInfo(evaluation.EmployeeId),
                LastEvaluator  = employeesService.GetEmployeeInfo(evaluation.LastEvaluatorId),
                CreatedDate    = evaluation.CreatedDate,
                ModifiedDate   = evaluation.ModifiedDate
            };

            return(evaluationViewModel);
        }
        public IActionResult Evaluate(int id)
        {
            var eval = evaluationsService.GetEvaluationById(id);
            EvaluationFormViewModel formVM = new EvaluationFormViewModel();

            formVM.Id             = eval.Id;
            formVM.Sections       = eval.Sections;
            formVM.FormName       = eval.FormName;
            formVM.EvaluationName = eval.EvaluationName;
            formVM.EmployeeName   = employeesService.GetEmployeeInfo(eval.EmployeeId).Name;
            formVM.IsCompleted    = eval.IsCompleted;
            formVM.SectionScales  = new Dictionary <int, SectionScaleViewModel>();
            //NOTE: each section has its own scale

            foreach (var section in eval.Sections)
            {
                var sectionScale = section.EvaluationScale;
                if (sectionScale != null)
                {
                    var scaleOptions   = evaluationsService.GetEvaluationScaleOptionsFromScale(sectionScale.Id);
                    var scaleOptionsVM = new SectionScaleViewModel()
                    {
                        SectionId = section.Id
                    };
                    var options = new List <SelectListItem>();
                    options.Add(new SelectListItem()
                    {
                        Value = "0", Text = "Not Evaluated"
                    });

                    options.AddRange(scaleOptions.Select(option =>
                                                         new SelectListItem
                    {
                        Value = "" + option.Id,
                        Text  = option.Name
                    })
                                     .ToList());
                    scaleOptionsVM.ScaleOptions = options;

                    formVM.SectionScales[section.Id] = scaleOptionsVM;
                }
            }

            return(View("EvaluationForm", formVM));
        }