private void detach_PredictionXRefs(PredictionXRef entity)
		{
			this.SendPropertyChanging();
			entity.Prediction = null;
		}
 partial void DeletePredictionXRef(PredictionXRef instance);
 partial void UpdatePredictionXRef(PredictionXRef instance);
 partial void InsertPredictionXRef(PredictionXRef instance);
        public ActionResult Rate(int id, FormCollection form)
        {
            var rate = Convert.ToInt32(form["score"]);
            Prediction prediction = repository.IncrementPredictionRating(rate, id);
            
            MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
            Guid currentUser = (Guid)user.ProviderUserKey;
            if (prediction.UserId == currentUser)
            {
                return RedirectToAction("Index", "Home");
            }
            var m = repository.CheckUserIdForRating(id, currentUser);
            if (m.Count() == 1)
            {
                return View("NotRating");
            }

            PredictionXRef xref = new PredictionXRef();
            xref.UserId = currentUser;
            prediction.PredictionXRefs.Add(xref);
            PreMembership predictor = repository.GetMember(prediction.UserId);
            if (predictor.Score == null)
                predictor.Score = 0;
            predictor.Score += rate;
            repository.Save();
            return RedirectToAction("Index", "Home");
        }
 public ActionResult RatePre(FormCollection form)
 {
     var rate = Convert.ToInt32(form["Score"]);
     var id = Convert.ToInt32(form["ArticleID"]);
     Prediction prediction = repository.IncrementPredictionRating(rate, id);
     MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
     Guid currentUser = (Guid)user.ProviderUserKey;
     var m = repository.CheckUserIdForRating(id, currentUser); 
     if (prediction.UserId == currentUser)
     {
         return Content("false");
     }
     else if (m.Count() == 1)
     {
         return Content("rated");
     }
     else
     {
         PredictionXRef xref = new PredictionXRef();
         xref.UserId = currentUser;
         PreMembership predictor = repository.GetMember(prediction.UserId);
         prediction.PredictionXRefs.Add(xref);
         if (predictor.Score == null)
             predictor.Score = 0;
         predictor.Score += rate;
         repository.Save();
         var countRater = repository.GetReference(id);
         var cc = countRater.Count();
         var AverageRating = Convert.ToDouble(prediction.Score) / Convert.ToDouble(cc);
         return Content(cc.ToString() + " voted; " + AverageRating.ToString());
     }
 }