示例#1
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);
            }
        }
示例#2
0
 public ActionResult MyPredict()
 {
     string Name = HttpContext.User.Identity.Name.ToString();
     CurrentUser.Name = Name;
     MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
     Guid guid = (Guid)user.ProviderUserKey;
     CurrentUser.Id = guid;
     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");
     return View(model);
 }
示例#3
0
        public ActionResult getAjaxTab(int id)  
        {
            string viewName = string.Empty;
            tabTextService serv = new tabTextService();
            tabViewModel myModel = serv.getTabViewModel();

            switch (id)
            {
                case 1:
                    viewName = "_tab1";
                    break;
                case 2:
                    viewName = "_tab2";
                    break;
                case 3:
                    viewName = "_tab3";
                    break;
                case 4:
                    viewName = "_error";
                    break;
            }

            System.Threading.Thread.Sleep(1000);

            return PartialView(viewName, myModel);
        }