Exemple #1
0
        public ActionResult Recommended_dog()
        {
            MLsController mls = new MLsController();
            Dictionary <string, double> result;

            result = mls.Calc(int.Parse(Session["ID"].ToString()));
            var test = result.ToArray();

            return(Json(test, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create([Bind(Include = "CommentID,GiverID,DogName,Sendername,Content")] Comment comment, int id)
        {
            MLsController mls = new MLsController();

            if (ModelState.IsValid)
            {
                var giver = db.Givers.Find(id);
                if (giver != null)
                {
                    comment.GiverID = giver.GiverID;
                    comment.Giver   = giver;
                    int dog_id = int.Parse(Session["DogID"].ToString());
                    var d      = db.Dogs.Where(b => b.DogID.Equals(dog_id)).FirstOrDefault();
                    if (d != null)
                    {
                        comment.DogName = d.Name;
                        db.Comments.Add(comment);
                        giver.Comments.Add(comment);
                        db.SaveChanges();


                        //add choise to machine learnin

                        int user_id = int.Parse(Session["ID"].ToString());
                        var user    = db.Users.Where(b => b.UserID.Equals(user_id)).FirstOrDefault();
                        if (user != null)
                        {
                            mls.Create(user_id, d.DogID, user.Age, user.Gender, user.FirstName, d.Breed);
                        }

                        //return after
                        // return RedirectToAction("Index", "FullGivers");
                    }
                    return(RedirectToAction("Index", "Dogs"));
                }
            }

            return(RedirectToAction("Index", "Dogs"));
        }