public JsonResult SetRating(string penname, string title, int id, string comment, int rating) { try { int ratingValue = CanUserVote(id, rating); if (ratingValue > 0) { return(Json(new { Success = false, Message = "Sorry, you already voted " + ratingValue.ToString() + " star(s) for this post." })); } BizInfo post = BizInfoRepository.SetBizInfoRating(id, rating); Vote v = VoteRepository.AddVote(0, id, title, penname, CurrentUserID, rating, CurrentUserIP, comment, DateTime.Now, UserName, DateTime.Now, UserName, true); return(Json(new { Success = true, Message = "Your Vote for " + Math.Abs(ratingValue).ToString() + " star(s) was cast successfully" // , Result = new { Rating = post.AverageRating, Raters = post.Votes } })); } catch { return(Json(new { Success = false, Message = "your vote was not casted successfully." })); } }