示例#1
0
        public string GetDatasets()
        {
            SentimentPy s   = new SentimentPy();
            string      res = s.getDatasets();

            return(res);
        }
        public JsonResult SentimentMinMax(string input)
        {
            SentimentPy s   = new SentimentPy();
            string      res = s.getSentimentMinMax(input);

            return(Json(res));
        }
        public JsonResult SentimentScore(string input)
        {
            SentimentPy s = new SentimentPy();

            float res = s.getSentimentScore(input);

            return(Json(res));
        }
示例#4
0
        public ActionResult Create([Bind(Include = "Id,Entry,UsersId,MentorId,SentimentScore,MentorFeedback,Date,MenteeFeedback")] DiaryEntries diaryEntries)
        {
            // Calculate the sentiment score of the text to save it in the database
            SentimentPy sent  = new SentimentPy();
            var         score = sent.getSentimentScore(diaryEntries.Entry);

            diaryEntries.SentimentScore = score;

            // Get the user's information and update the diary before saving it
            ApplicationUser user        = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId <int>());
            Users           currentUser = db.Users.Find(user.Id);

            diaryEntries.UsersId  = currentUser.Id;
            diaryEntries.MentorId = currentUser.MentorId.Value;
            diaryEntries.Date     = DateTime.Now;

            if (ModelState.IsValid)
            {
                // Save changes to DB
                db.DiaryEntries.Add(diaryEntries);
                db.SaveChanges();
                // Send e-mail to mentor
                EmailController mail        = new EmailController();
                var             UserManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
                var             users       = UserManager.FindById(diaryEntries.MentorId);
                Users           mentor      = db.Users.Find(users.Id);
                mail.NewDiary(users.Email, mentor.FirstName, currentUser.FirstName, currentUser.LastName);

                // Type options : info, danger, success, warning
                TempData["UserMessage"] = new JavaScriptSerializer().Serialize(new { Type = "success", Title = "Success!", Message = "Diary entry added correctly!" });

                return(View());
            }

            ViewBag.UsersId = new SelectList(db.Users, "Id", "FirstName", diaryEntries.UsersId);
            return(View(diaryEntries));
        }