Example #1
0
        public ActionResult Index(Prediction prediction)
        {
#region Use when validate data
            var iportends = repository.RecentPrediction().ToList();
            ViewData["categories"] = new SelectList(repository.categoryList(), "CategoryID", "Description");
            //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;
            //
            var i = 0;
            foreach (var m in top)
            {
                if (m.UserName == HttpContext.User.Identity.Name)
                {
                    i = i + 1;
                    break;
                }
                i = i + 1;
            }
            ViewData["ranking"] = i.ToString();
            
#endregion
            prediction.InsertDate = DateTime.Now;
            MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
            Guid guid = (Guid)user.ProviderUserKey;

            /******* Show score in Left column under photo**********/
            PreMembership predictor = repository.GetMember(guid);
            if (predictor.Score.HasValue)
            {
                ViewData["Score"] = predictor.Score.ToString();
            }
            else
            {
                ViewData["Score"] = "0";
            }
            /*************************************************/

            prediction.UserId = guid;
            prediction.RateID = 1;
            prediction.IsActive = true;
            repository.Add(prediction);
            try
            {
                repository.Save();
                return RedirectToAction("Index");
            }
            catch
            {
                ModelState.AddRuleViolations(prediction.GetRuleViolations());
                return View(iportends);
            }

        }
Example #2
0
        public ActionResult MyPredict(Prediction prediction)
        {
#region Use when validate data -------------------------------------
            string Name = User.Identity.Name.ToString();
            CurrentUser.Name = Name;
            tabTextService serv = new tabTextService();
            tabViewModel model = serv.getTabViewModel();
            //Recent comment from other member
            List<DetailComment> commentOther = repository.GetCommentfromOther(Name).ToList();
            ViewData["RecentComOther"] = commentOther;
            //
            //Recent comment from current member
            List<DetailComment> commentYourself = repository.GetCommentFromCurrent(Name).ToList();
            ViewData["RecentComCurrent"] = commentYourself;
            //
            //Show predictor that vote
            List<VisitedPredictor> prevote = repository.GetUserThatVote(Name).ToList();
            ViewData["PredictorVote"] = prevote;
            //
            // Show list of prediction that rated by current member
            List<CMDetailPrediction> cMemberR = repository.GetTopic(Name).ToList();
            ViewData["CurrentMemberVote"] = cMemberR;
            //
            //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;
            //
            ViewData["CategoryList"] = new SelectList(repository.categoryList(), "CategoryID", "Description");
#endregion -----------------------------------------------------------
            prediction.InsertDate = DateTime.Now;
            MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
            Guid guid = (Guid)user.ProviderUserKey;
            prediction.UserId = guid;
            prediction.RateID = 1;
            prediction.IsActive = true;
            repository.Add(prediction);
            try
            {
                repository.Save();
                return RedirectToAction("MyPredict");
            }
            catch 
            {
                ModelState.AddRuleViolations(prediction.GetRuleViolations());
                return View(model);
            }
        }
Example #3
0
        public ActionResult Home(Prediction prediction) 
        {
            var iportends = repository.RecentPrediction().ToList();
            ViewData["categories"] = new SelectList(repository.categoryList(), "CategoryID", "Description");

            prediction.InsertDate = DateTime.Now;
            var m = Session["user"].ToString();
            prediction.RateID = 1;
            prediction.IsActive = true;
            repository.Add(prediction);
            try
            {
                repository.Save();
                return RedirectToAction("Home");
            }
            catch
            {
                ModelState.AddRuleViolations(prediction.GetRuleViolations());
                return View(iportends);
            }
        }
Example #4
0
 partial void DeletePrediction(Prediction instance);
Example #5
0
 partial void UpdatePrediction(Prediction instance);
Example #6
0
 partial void InsertPrediction(Prediction instance);
Example #7
0
        public ActionResult Create(Prediction prediction)
        {
            
                prediction.InsertDate = DateTime.Now;
                //if (User.Identity.IsAuthenticated)
                //{
                    MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
                    Guid guid = (Guid)user.ProviderUserKey;
                    prediction.UserId = guid;
                    prediction.RateID = 1;
                    prediction.IsActive = true;
                    repository.Add(prediction);
                 //}
            try
            {
                repository.Save();
                return RedirectToAction("Index");
            }
            catch 
            {
                ModelState.AddRuleViolations(prediction.GetRuleViolations());
                return View(prediction);
            }

        }
 public void Add(Prediction prediction)
 {
       dataContext.Predictions.InsertOnSubmit(prediction);
 }
 /// <summary>
 /// Delete prediction's current user
 /// </summary>
 /// <param name="prediction"></param>
 public void Delete(Prediction prediction)
 {
     dataContext.PredictionXRefs.DeleteAllOnSubmit(prediction.PredictionXRefs);
     dataContext.Predictions.DeleteOnSubmit(prediction);
 }