Exemplo n.º 1
0
        public ActionResult WxVoteMainView(int id)
        {
            var eventId = Request["eventId"];
            var lillyid = ViewBag.LillyId;

            if (string.IsNullOrEmpty(lillyid))
            {
                return(Redirect("/notauthed.html"));
            }

            if (id != 0)
            {
                var pol = _objService.Repository.Entities.AsNoTracking().Where(a => a.Id == id).FirstOrDefault();
                if (pol == null || pol.IsDeleted == true)
                {
                    return(View("../Polling/WxDeletedView"));;
                }
                var poll      = (PollingView) new PollingView().ConvertAPIModel(pol);
                int userCount = _objResultService.GetUserCount(id, lillyid);
                if (!string.IsNullOrEmpty(eventId))
                {
                    poll.EventId = eventId;
                }

                if (poll.Type == 1 && userCount > 0)
                {
                    return(View("../Polling/WxQADetailView", poll));
                }
                else if ((poll.Type == 2 || poll.Type == 3) && userCount > 0)
                {
                    poll = _objService.GetPollingVote(id, lillyid);
                    if (!string.IsNullOrEmpty(eventId))
                    {
                        poll.EventId = eventId;
                    }
                    return(View("../Polling/WxVoteDetailView", poll));
                }

                else
                {
                    //poll = _objService.GetPollingDetailView(query, lillyid);
                    poll = _objService.GetPollingDetailView(id);
                    if (!string.IsNullOrEmpty(eventId))
                    {
                        poll.EventId = eventId;
                    }
                    return(View("../Polling/WxVoteView", poll));
                }
            }
            return(View());
        }
        public ActionResult WxVoteMain(int id)
        {
            var eventId = Request["eventId"];
            var lillyid = User.Identity.Name;

            if (string.IsNullOrEmpty(lillyid))
            {
                return(Json(new { Status = WxVoteType.NotAuthed, Message = "未授权" }, JsonRequestBehavior.AllowGet));
            }

            if (id != 0)
            {
                var pol = _objService.Repository.Entities.AsNoTracking().Where(a => a.Id == id).FirstOrDefault();
                if (pol == null || pol.IsDeleted == true)
                {
                    return(Json(new { Status = WxVoteType.Deleted, Message = "已删除" }, JsonRequestBehavior.AllowGet));
                }
                var poll = (PollingView) new PollingView().ConvertAPIModel(pol);

                int userCount = _objResultService.GetUserCount(id, lillyid);

                if (!string.IsNullOrEmpty(eventId))
                {
                    poll.EventId = eventId;
                }

                if (poll.Type == 1 && userCount > 0)
                {
                    return(Json(new { Status = WxVoteType.NotVotedQA, Message = "有奖问答", data = poll }, JsonRequestBehavior.AllowGet));
                }
                else if ((poll.Type == 2 || poll.Type == 3) && userCount > 0)
                {
                    poll = _objService.GetPollingVote(id, lillyid);
                    if (!string.IsNullOrEmpty(eventId))
                    {
                        poll.EventId = eventId;
                    }
                    return(Json(new { Status = WxVoteType.NotVotedQA, Message = "投票", data = poll }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    poll = _objService.GetPollingDetailView(id);
                    if (!string.IsNullOrEmpty(eventId))
                    {
                        poll.EventId = eventId;
                    }
                    return(Json(new { Status = WxVoteType.NotVotedQA, Message = "投票", data = poll }, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(new { Status = WxVoteType.Deleted, Message = "已删除/不存在" }, JsonRequestBehavior.AllowGet));
        }