partial void DeleteComment(Comment instance);
partial void UpdateComment(Comment instance);
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); } }
partial void InsertComment(Comment instance);
/// <summary> /// Create comment /// </summary> /// <param name="comment"></param> public void Addcomment(Comment comment) { dataContext.Comments.InsertOnSubmit(comment); }