Пример #1
0
		private void detach_PredictionXRefs(PredictionXRef entity)
		{
			this.SendPropertyChanging();
			entity.Prediction = null;
		}
Пример #2
0
 partial void DeletePredictionXRef(PredictionXRef instance);
Пример #3
0
 partial void UpdatePredictionXRef(PredictionXRef instance);
Пример #4
0
 partial void InsertPredictionXRef(PredictionXRef instance);
Пример #5
0
        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");
        }
Пример #6
0
 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());
     }
 }