示例#1
0
        private VoteModel GetVoteModel(VoteProject voteProject)
        {
            //Get the VoteItems
            var voteItems = db.VoteItems.Where(i => i.PId == voteProject.Id && i.State == 0).ToList();
            var userId = User.Identity.Name.Split(',')[0];
            var voteDetails = db.VoteDetails.Where(d => d.State == 0 && d.PId == voteProject.Id && d.Voter == userId);

            var itemModels = new List<VoteItemModel>();

            foreach (var i in voteItems)
            {
                var itemModel = new VoteItemModel()
                {
                    Id = i.Id,
                    Comment = i.Comment,
                    PId = i.PId,
                    Name = i.Name,
                    Members = i.Nominees,
                    Nominator = i.Nominator,
                    State = 0
                };

                var detail = voteDetails.FirstOrDefault(d => d.IId == i.Id);

                itemModel.IsSelected = detail == null;//?false:true;
                itemModel.PreSelected = detail != null;//?false:true;

                itemModels.Add(itemModel);
            }

            var voteModel = new VoteModel() { Items = itemModels, Project = voteProject, CurrentUserVoteNum = voteDetails.ToList().Count };

            return voteModel;
        }
示例#2
0
        private ActionResult GetVoteResultView(VoteProject voteProject)
        {
            if (voteProject == null)
            {
                ViewBag.Message = "Wowo~~, we cannot find the vote.";
                return View("Alert");
            }

            var itemModels = GetVoteItems(voteProject.Id);

            var voteModel = new VoteModel() { Items = itemModels.OrderByDescending(i => i.Count).ToList(), Project = voteProject };

            return View("Result", voteModel);
        }
示例#3
0
        public ActionResult ItemList(int id)
        {
            var voteProject = GetVoteProject(id);

            if (voteProject == null)
            {
                ViewBag.Message = "oops~~, we cannot find the vote.";
                return View("Alert");
            }

            id = voteProject.Id;

            var itemModels = GetVoteItems(id);

            var voteModel = new VoteModel() { Items = itemModels, Project = voteProject };

            return View("ItemList", voteModel);
        }