Ejemplo n.º 1
0
        public async Task <ActionResult> ListUnfilledCriteriaComparisons()
        {
            ViewBag.Title = "Unfilled criteria comparisons";

            var critcomps = await _criteriaComparisonService.GetUnfilledAsync((Guid)Session["ChoiceID"]);

            var _critcomps = new List <CriteriaComparisonMvcModel>();
            IDictionary <Guid, string> CritNames = (IDictionary <Guid, string>)Session["CriteriaNames"];

            foreach (ICriteriaComparisonModel critcomp in critcomps)
            {
                Guid critID1 = critcomp.CriteriaID1;
                Guid critID2 = critcomp.CriteriaID2;

                double newcritratio = 0;

                CriteriaComparisonMvcModel cc = new CriteriaComparisonMvcModel
                {
                    CriterionName1 = CritNames[critID1],
                    CriterionID1   = critID1,
                    CriterionID2   = critID2,
                    CriterionName2 = CritNames[critID2],
                    Flipped        = false,
                    CriteriaRatio  = newcritratio
                };

                _critcomps.Add(cc);
            }
            if (!_critcomps.Any())
            {
                return(RedirectToAction("ListCriteria", "Criterion", new { page = Session["Page"] }));
            }

            return(View(_critcomps));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> ListCriteriaComparisons(int page)
        {
            ViewBag.Title = "Criteria comparisons";
            if (page < 1)
            {
                page = 1;
            }
            Session["Page"] = page;

            var critcomps = await _criteriaComparisonService.GetAsync((Guid)Session["CriterionID"], page);

            var  _critcomps = new List <CriteriaComparisonMvcModel>();
            Guid critID     = (Guid)Session["CriterionID"];
            IDictionary <Guid, string> CritNames = (IDictionary <Guid, string>)Session["CriteriaNames"];

            foreach (ICriteriaComparisonModel critcomp in critcomps)
            {
                Guid critID1 = critcomp.CriteriaID1;
                Guid critID2 = critcomp.CriteriaID2;

                if (critID1 == critID)
                {
                    //OVO S NUOOM je samo za test
                    double newcritratio;
                    if (critcomp.CriteriaRatio != 0)
                    {
                        newcritratio = critcomp.CriteriaRatio;
                        //Pretvara u oblik koji je prihvatljiv sliderima
                        if (newcritratio < 1)
                        {
                            newcritratio = -(Math.Round(1 / critcomp.CriteriaRatio) - 1);
                        }
                        else
                        {
                            newcritratio -= 1;
                        }
                    }
                    else
                    {
                        newcritratio = 0;
                    }
                    CriteriaComparisonMvcModel cc = new CriteriaComparisonMvcModel
                    {
                        CriterionName1 = CritNames[critID1],
                        CriterionID1   = critID1,
                        CriterionID2   = critID2,
                        CriterionName2 = CritNames[critID2],
                        Flipped        = false,
                        CriteriaRatio  = newcritratio
                    };

                    _critcomps.Add(cc);
                }
                else
                {
                    double newcritratio;
                    if (critcomp.CriteriaRatio != 0)
                    {
                        newcritratio = 1 / critcomp.CriteriaRatio;
                        //OVO SA NULOM POSLJE OBRISAT
                        //Pretvara u oblik koji je prihvatljiv sliderima
                        if (newcritratio < 1)
                        {
                            newcritratio = -(Math.Round(1 / newcritratio) - 1);
                        }
                        else
                        {
                            newcritratio -= 1;
                        }
                    }
                    else
                    {
                        newcritratio = 0;
                    }

                    CriteriaComparisonMvcModel cc = new CriteriaComparisonMvcModel
                    {
                        CriterionName1 = CritNames[critID2],
                        CriterionID1   = critID2,
                        CriterionID2   = critID1,
                        CriterionName2 = CritNames[critID1],
                        Flipped        = true,
                        CriteriaRatio  = newcritratio
                    };

                    _critcomps.Add(cc);
                }
            }
            if (!_critcomps.Any() && page > 1)
            {
                Session["Page"] = page - 1;
                return(RedirectToAction("ListCriteriaComparisons", "CriteriaComparison", new { page = Session["Page"] }));
            }

            return(View(_critcomps));
        }