Esempio n. 1
0
 private static FillRatingsViewModel GetFillRatingsViewModel(Project project, FillRatingsViewModel existing = null)
 {
     existing = existing ?? new FillRatingsViewModel();
     var firstAlternative = project.Alternatives.First();
     existing.Ratings = project.WeightGenerationResults.Select(x => new FillRatingsItemModel()
     {
         WeightId = x.WeightGenerationResultId,
         Method = x.GenerationMethod,
         FactorNames = x.GetFirstAlternativeFactors().Select(factor => factor.Factor.FactorName).ToList(),
     }).ToList();
     return existing;
 }
Esempio n. 2
0
        public virtual ActionResult FillRatings(int id, AggregationType aggregationType, FillRatingsViewModel viewModel)
        {
            Project project = _projectService.Get(id);

            if (ModelState.IsValid)
            {
                foreach (var rating in viewModel.Ratings)
                {
                    var weight = project.WeightGenerationResults.Single(x => x.WeightGenerationResultId == rating.WeightId);
                    var factors = weight.GetFirstAlternativeFactors().ToList();

                    for (int i = 0; i < factors.Count; i++)
                    {
                        weight.Items.Where(x => x.FactorId == factors[i].FactorId).ToList().ForEach(x => x.Rating = rating.Values[i].GetValue());
                    }
                }

                _projectService.Update(project);

                return RedirectToAction(MVC.Projects.DoAggregation(id, aggregationType));
            }

            viewModel = GetFillRatingsViewModel(project, viewModel);
            ViewBag.Title = ViewTitles.FillRatings;
            return View(viewModel);
        }