Пример #1
0
 partial void DeleteComment(Comment instance);
Пример #2
0
 partial void UpdateComment(Comment instance);
Пример #3
0
        public ActionResult Comment(int id,Comment comment)
        {
#region Show when validate data 
            DetailPrediction detail = repository.ShowDetail(id);
            var m = repository.CountComment(id);
            ViewData["NComment"] = m.Count().ToString();
            //show comment
            List<DetailComment> showcomments = repository.ShowComment(id).ToList();
            ViewData["showComment"] = showcomments;
            //
            //show in amazing.ascx
            List<TopPrediction> amazing = repository.GetTopPredict().ToList();
            ViewData["AmazingPredict"] = amazing;
            //
            //show in TopPredictor.ascx
            List<TopPredictor> top = repository.GetTopPredictor().ToList();
            ViewData["TopUser"] = top;
            //
#endregion
            comment.PredictionID = id;
            Prediction prediction = repository.GetPrediction(id);
            MembershipUser member = Membership.GetUser(HttpContext.User.Identity.Name);
            Guid currentuser = (Guid)member.ProviderUserKey;
            var ss = repository.CheckUserIdForRating(id, currentuser);
            if (prediction.UserId == currentuser || ss.Count() == 1)
            {
                ViewData["checkRated"] = "true";
            }
            var countRater = repository.GetReference(id);
            var cc = countRater.Count();
            var AverageRating = Convert.ToDouble(prediction.Score) / Convert.ToDouble(cc);
            ViewData["totalRaters"] = cc.ToString() + " votes; " + AverageRating;
            ViewData["avg"] = AverageRating;

            comment.UserId = currentuser;
            repository.Addcomment(comment);
            try
            {
                repository.Save();
                return RedirectToAction("Comment", "Profile", id);
            }
            catch
            {
                ModelState.AddRuleViolations(comment.GetRuleViolations());
                return View(detail);
            }
        }
Пример #4
0
 partial void InsertComment(Comment instance);
Пример #5
0
 /// <summary>
 /// Create comment
 /// </summary>
 /// <param name="comment"></param>
 public void Addcomment(Comment comment)
 {
     dataContext.Comments.InsertOnSubmit(comment);
 }