public virtual ActionResult ManualAssessment(int id, ManualAssessmentViewModel viewModel) { var target = CurrentUser.Assesments.SingleOrDefault(assessment => assessment.ProjectId == id); if (ModelState.IsValid) { target.Items.Clear(); target.Items = viewModel.Items.Select(item => new ExpertAssessmentItem() { AlternativeId = item.AlternativeId, FactorId = item.FactorId, Points = item.GetPoints() }).ToList(); _projectService.Update(target.Project); return(RedirectToAction(MVC.Assessments.Details(id))); } foreach (var item in viewModel.Items) { item.AlternativeName = target.Project.Alternatives.First(x => x.AlternativeId == item.AlternativeId).AlternativeName; item.FactorName = target.Project.Factors.First(x => x.FactorId == item.FactorId).FactorName; } return(View(viewModel)); }
public virtual ActionResult ManualAssessment(int id) { var target = CurrentUser.Assesments.SingleOrDefault(assessment => assessment.ProjectId == id); ManualAssessmentViewModel viewModel = new ManualAssessmentViewModel(); var alternatives = target.Project.Alternatives; var factors = target.Project.Factors; foreach (var alternative in alternatives.OrderBy(x => x.AlternativeId)) { foreach (var factor in factors.OrderBy(x => x.FactorId)) { viewModel.Items.Add(new ManualAssessmentViewModelItem() { AlternativeId = alternative.AlternativeId, AlternativeName = alternative.ToString(), FactorId = factor.FactorId, FactorName = factor.ToString() }); } } return(View(viewModel)); }