Пример #1
0
        public ActionResult RateAccomodation(StuAccomRatings stuAccomRatings)
        {
            if (ModelState.IsValid)
            {
                Rater r = new Rater();

                r.safety  = stuAccomRatings.safety;
                r.service = stuAccomRatings.service;
                r.StudentAccomodationId = (int)TempData["RatingID"];
                r.UsersId = 19;
                r.review  = stuAccomRatings.review;

                try
                {
                    SaveRating(r, stuAccomRatings);
                    treedatStore.Rater.Add(r);
                    treedatStore.SaveChanges();
                }
                catch (Exception e)
                {
                    e.ToString();
                }
            }

            return(View());
        }
Пример #2
0
        public int SaveRating(Rater rateings, StuAccomRatings studentAccomodation)
        {
            SentimentAnalysis sentiment = new SentimentAnalysis();

            if (ModelState.IsValid)
            {
                c2t      = new ConvertToText();
                treeNode = c2t.RetrieveTree();

                foreach (ChildNode node in treeNode.ChildNodes)
                {
                    if (node.data == studentAccomodation.IncomeGroup)
                    {
                        foreach (ChildNode area in node.Child)
                        {
                            if (area.data == studentAccomodation.location)
                            {
                                foreach (ChildNode acomodation in area.Child)
                                {
                                    if (studentAccomodation.Name == acomodation.data)
                                    {
                                        int val = acomodation.Id;
                                        if (val > 0)
                                        {
                                            acomodation.Id = (val + (rateings.safety + rateings.service)) / 2;
                                        }
                                        else
                                        {
                                            acomodation.Id = rateings.safety + rateings.service;
                                        }
                                        acomodation.safety = rateings.safety;

                                        acomodation.sentiment += sentiment.DeterminePolarity(studentAccomodation.review);

                                        var t = treeNode;


                                        c2t.SaveTree(treeNode);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                return(1);
            }

            return(-1);
        }
Пример #3
0
        public ActionResult RateAccomodation(int RateId)
        {
            StuAccomRatings stuaccomratings = new StuAccomRatings();

            try
            {
                var stu = treedatStore.StudentAccomodation.Where(c => c.Id == RateId).FirstOrDefault();
                Id = stu.Id;

                TempData["RatingID"]        = Id;
                stuaccomratings.Name        = stu.Name;
                stuaccomratings.IncomeGroup = stu.IncomeGroup;
                stuaccomratings.location    = stu.location;
                stuaccomratings.ImageUrl    = stu.ImageUrl;
                stuaccomratings.Description = "mnjhbvfjdksld sdmckvjhcdjkfv dkcjhdnjcvhbgd";

                return(View(stuaccomratings));
            }catch (Exception e)
            {
                e.ToString();
            }

            return(View());
        }