Exemple #1
0
        public async Task <ActionResult> CreateCriterion(CriterionMvcModel model)
        {
            if (ModelState.IsValid)
            {
                ICriterionModel _criterion = new CriterionModel {
                    ChoiceID = (Guid)Session["ChoiceID"], CriteriaName = model.CriteriaName
                };
                var status = await _criterionService.AddAsync(_criterion);

                var caltcomps = await _alternativeComparisonService.GetUnfilledAsync((Guid)Session["ChoiceID"]);

                if (caltcomps.Any())
                {
                    Session["AnyUnfilledAlt"] = true;
                }
                else
                {
                    Session["AnyUnfilledAlt"] = false;
                }
                var critcomps = await _criteriaComparisonService.GetUnfilledAsync((Guid)Session["ChoiceID"]);

                if (critcomps.Any())
                {
                    Session["AnyUnfilledCrit"] = true;
                }
                else
                {
                    Session["AnyUnfilledCrit"] = false;
                }
                return(RedirectToAction("ListCriteria", "Criterion", new { page = Session["Page"] }));
            }
            return(View());
        }
Exemple #2
0
        public async Task <ActionResult> EditChoice(Guid choiceID)
        {
            Session["ChoiceID"] = choiceID;
            var caltcomps = await _alternativeComparisonService.GetUnfilledAsync((Guid)Session["ChoiceID"]);

            if (caltcomps.Any())
            {
                Session["AnyUnfilledAlt"] = true;
            }
            else
            {
                Session["AnyUnfilledAlt"] = false;
            }
            var critcomps = await _criteriaComparisonService.GetUnfilledAsync((Guid)Session["ChoiceID"]);

            if (critcomps.Any())
            {
                Session["AnyUnfilledCrit"] = true;
            }
            else
            {
                Session["AnyUnfilledCrit"] = false;
            }
            Session["Page"] = 1;
            ViewBag.Title   = "List Alternatives";
            var choice = await _choiceService.GetByIdAsync(choiceID);

            Session["ChoiceName"] = choice.ChoiceName;
            return(RedirectToAction("ListAlternatives", "Alternative", new { page = Session["page"] }));
        }
        public async Task <ActionResult> ListUnfilledAlternativeComparisons()
        {
            ViewBag.Title = "Unfilled alternative comparisons";

            var caltcomps = await _alternativeComparisonService.GetUnfilledAsync((Guid)Session["ChoiceID"]);

            var _caltcomps = new List <AlternativeComparisonMvcModel>();
            IDictionary <Guid, string> CritNames = (IDictionary <Guid, string>)Session["CriteriaNames"];
            IDictionary <Guid, string> AltNames  = (IDictionary <Guid, string>)Session["AlternativesNames"];

            foreach (IAlternativeComparisonModel altcomp in caltcomps)
            {
                Guid altID1 = altcomp.AlternativeID1;
                Guid altID2 = altcomp.AlternativeID2;

                double newaltratio = 0;

                AlternativeComparisonMvcModel ac = new AlternativeComparisonMvcModel
                {
                    CriteriaID       = altcomp.CriteriaID,
                    CriteriaName     = CritNames[altcomp.CriteriaID],
                    AlternativeID1   = altID1,
                    AlternativeName1 = AltNames[altID1],
                    AlternativeID2   = altID2,
                    AlternativeName2 = AltNames[altID2],
                    Flipped          = false,
                    AlternativeRatio = newaltratio
                };

                _caltcomps.Add(ac);
            }
            if (!_caltcomps.Any())
            {
                return(RedirectToAction("ListAlternatives", "Alternative", new { page = Session["Page"] }));
            }

            return(View(_caltcomps));
        }
        public async Task <ActionResult> CreateAlternative(AlternativeMvcModel model)
        {
            if (ModelState.IsValid)
            {
                IAlternativeModel _alternative = new AlternativeModel {
                    ChoiceID = (Guid)Session["ChoiceID"], AlternativeName = model.AlternativeName
                };
                var status = await _alternativeService.AddAsync(_alternative);

                var caltcomps = await _alternativeComparisonService.GetUnfilledAsync((Guid)Session["ChoiceID"]);

                if (caltcomps.Any())
                {
                    Session["AnyUnfilledAlt"] = true;
                }
                else
                {
                    Session["AnyUnfilledAlt"] = false;
                }
                return(RedirectToAction("ListAlternatives", "Alternative", new { page = Session["Page"] }));
            }
            return(View());
        }