Beispiel #1
0
        public IActionResult Index()
        {
            List <STORatingViewModel> stos = new List <STORatingViewModel>();
            List <Evaluation>         eval = new List <Evaluation>();

            foreach (var s in _db.Evaluation)
            {
                eval.Add(s);
            }

            foreach (var s in _db.STO)
            {
                double rating = 0;
                int    i      = 0;
                foreach (var e in eval)
                {
                    if (e.STOId == s.Id)
                    {
                        rating = rating + e.Eval;
                        i++;
                    }
                }

                STORatingViewModel model = new STORatingViewModel()
                {
                    Id      = s.Id,
                    Name    = s.Name,
                    Raiting = rating / i
                };

                stos.Add(model);
            }

            return(View(stos));
        }
Beispiel #2
0
        public IActionResult List()
        {
            var servises = Request.Form;
            HashSet <STORatingViewModel> sto = new HashSet <STORatingViewModel>();

            List <Evaluation> eval = new List <Evaluation>();

            foreach (var s in _db.Evaluation)
            {
                eval.Add(s);
            }

            var r = servises.FirstOrDefault(s => s.Key == "Rajon");

            if (servises.Count == 2)
            {
                foreach (var s in _db.STO)
                {
                    if (s.Rajon.Contains(r.Value))
                    {
                        double rating = 0;
                        int    i      = 0;
                        foreach (var e in eval)
                        {
                            if (e.STOId == s.Id)
                            {
                                rating = rating + e.Eval;
                                i++;
                            }
                        }

                        STORatingViewModel model = new STORatingViewModel()
                        {
                            Id      = s.Id,
                            Name    = s.Name,
                            Raiting = rating / i
                        };
                        sto.Add(model);
                    }
                }
                return(View(sto));
            }

            foreach (var service in servises)
            {
                if (service.Key == "__RequestVerificationToken" || service.Key == "Rajon")
                {
                    continue;
                }

                foreach (var s in _db.STO)
                {
                    if (s.Services.Contains(service.Value) && s.Rajon.Contains(r.Value))
                    {
                        double rating = 0;
                        int    i      = 0;
                        foreach (var e in eval)
                        {
                            if (e.STOId == s.Id)
                            {
                                rating = rating + e.Eval;
                                i++;
                            }
                        }

                        STORatingViewModel model = new STORatingViewModel()
                        {
                            Id      = s.Id,
                            Name    = s.Name,
                            Raiting = rating / i
                        };
                        sto.Add(model);
                    }
                }
            }
            return(View(sto));
        }