public ActionResult GetVoteMemberByType(string vid, string vtype) { VoteBL v = VoteBL.GetVote(vid); if (!string.IsNullOrEmpty(vtype) && vtype != "ALL") { v.VoteMember = v.VoteMember.Where(p => p.OptionTitle == vtype).ToList(); } VoteMemberlistVM ms = new VoteMemberlistVM(); ms.total = v.VoteMember.Count; VoteMemberVM m; ms.rows = new List <VoteMemberVM>(); for (int i = 0; i < v.VoteMember.Count; i++) { m = new VoteMemberVM(); m.name = "<img src='" + v.VoteMember[i].Avatar + "' />" + v.VoteMember[i].Name; m.title = v.VoteMember[i].OptionTitle; m.context = v.VoteMember[i].OptinContext; m.picurl = v.VoteMember[i].Avatar; ms.rows.Add(m); } return(Json(ms)); }
public ActionResult GetVoteRes(string id) { VoteBL v = VoteBL.GetVote(id); int sum = v.VoteMember.Count; VoteOptResVM orv; VoteResVM list = new VoteResVM(); list.opts = new List <VoteOptResVM>(); list.vtype = v.vtype; list.vnum = sum; v.Options.ForEach(p => { orv = new VoteOptResVM(); orv.title = p.OptinContext; orv.num = p.VoteMember.Count; if (sum == 0) { orv.persent = 0; } else { orv.persent = Convert.ToInt32(Math.Round((((double)p.VoteMember.Count) * 100 / sum), 0)); } list.opts.Add(orv); }); return(Json(list)); }
// // GET: /Test/ public ActionResult Index() { //QYDepartmentBL p = QYDepartmentBL.GetAllDepartments(); //Json(p); // QYDepartmentBL dep = p.Departments.Find(g => g.DepartmentID == "13"); // QYDepartmentBL.DownloadDatafromWX(); //dep.ParentDepartmentID = "12"; //dep.UpdateDepartment("1", ref errMsg); //QYMemberBL member = new QYMemberBL(); //string errMsg = ""; //member.Email = "*****@*****.**"; //member.UserId = "boiis12223"; //member.Name = "Nick3"; //member.DepartmentPKId = 3; //member.AddMember("1", ref errMsg, "13"); //member.DepartmentPKId = 3; //member.DepartmentWXId = "12"; //member.UpdateMember("1", ref errMsg); //member.AddMember(); VoteBL v = VoteBL.GetVote("1"); //v.Options[1].OptionTitle = "234"; //v.UpdateVote(); List <VoteMember> l = v.VoteMember; //VoteCollection vc = new VoteCollection(); //v.Title = v.Title + "we"; //v.Context = "^_^" + v.Context; //v.Options[2].OptinContext = "^_^" + v.Options[2].OptinContext; //v.Options[1].ActionType="2"; //v.Options.Add(new VoteOption(){ CreateBy="1", OptinContext="111", ActionType="1"}); //v.UpdateBy = "1"; //v.UpdateVote(); //VoteBL v2 = new VoteBL(); //v2.Title = "123"; //v2.CreateBy = "1"; //v2.Context = "2132131"; //v2.vtype = "1"; //v2.PicUrl = ""; //v2.Options = new List<VoteOption>() { // new VoteOption(){ CreateBy="1", OptinContext="111"}, // new VoteOption(){ CreateBy="1", OptinContext="222"}, // new VoteOption(){ CreateBy="1", OptinContext="333"} //}; //v2.AddVote(); return(View()); }
public ActionResult DeleteVote(string id) { VoteBL v = VoteBL.GetVote(id); v.DeleteBy = "1"; if (v.DeleteVote()) { return(Json(new { rescode = 200, msg = "" })); } else { return(Json(new { rescode = 500, msg = "操作失敗" })); } }
public ActionResult UpdateVote(AddvoteVM vote) { VoteBL v = VoteBL.GetVote(vote.id); v.Title = vote.title; v.UpdateBy = "1"; v.vtype = vote.vtype; v.Context = vote.context; for (int i = 0; i < v.Options.Count; i++) { if (!vote.options.Exists(p => p.id == v.Options[i].ID.ToString())) { v.Options[i].ActionType = "2"; } } VoteOption vop; for (int i = 0; i < vote.options.Count; i++) { if (v.Options.Exists(p => p.ID.ToString() == vote.options[i].id)) { vop = v.Options.Find(p => p.ID.ToString() == vote.options[i].id); vop.OptinContext = vote.options[i].OptinContext; vop.OptionTitle = vote.options[i].OptionTitle; vop.UpdateBy = "1"; vop.ActionType = null; } else { vop = new VoteOption(); vop.OptinContext = vote.options[i].OptinContext; vop.OptionTitle = vote.options[i].OptionTitle; vop.UpdateBy = "1"; vop.ActionType = "1"; v.Options.Add(vop); } } if (v.UpdateVote()) { return(Json(new { rescode = 200, msg = "" })); } else { return(Json(new { rescode = 500, msg = "操作失敗" })); } }
public ActionResult VoteMobelForShow(string id) { //string code = Request.QueryString["code"]; //QYConfig.RegistWX(); //var accessToken = AccessTokenContainer.GetToken(QYConfig.CorpId); //GetUserIdResult user = OAuth2Api.GetUserId(accessToken, code, QYConfig.VoteAgenID); //QYMemberBL member = QYMemberBL.GetMemberByWXID(user.UserId); ViewBag.userid = ""; ViewBag.vid = id; MemberVote mv = new MemberVote(); mv.opts = new List <VoteOption>(); ViewBag.mv = mv; VoteBL v = VoteBL.GetVote(id); return(View(v)); }
public ActionResult VoteMobel(string id) { string code = Request.QueryString["code"]; QYConfig.RegistWX(); var accessToken = AccessTokenContainer.GetToken(QYConfig.CorpId); GetUserIdResult user = OAuth2Api.GetUserId(accessToken, code, QYConfig.VoteAgenID); QYMemberBL member = QYMemberBL.GetMemberByWXID(user.UserId); ViewBag.userid = member.ID; ViewBag.vid = id; MemberVote mv = new MemberVote(member.ID.ToString(), id); ViewBag.mv = mv; VoteBL v = VoteBL.GetVote(id); return(View(v)); }
public ActionResult GetVoteMember(string id) { VoteBL v = VoteBL.GetVote(id); VoteMemberlistVM ms = new VoteMemberlistVM(); ms.total = v.VoteMember.Count; VoteMemberVM m; ms.rows = new List <VoteMemberVM>(); for (int i = 0; i < v.VoteMember.Count; i++) { m = new VoteMemberVM(); m.name = "<img style='width:30px' src='" + v.VoteMember[i].Avatar + "' />" + v.VoteMember[i].Name; m.title = v.VoteMember[i].OptionTitle; m.context = v.VoteMember[i].OptinContext; m.picurl = v.VoteMember[i].Avatar; ms.rows.Add(m); } return(Json(ms)); }
public ActionResult GetVote(string id) { VoteBL v = VoteBL.GetVote(id); AddvoteVM avm = new AddvoteVM(); avm.id = v.ID.ToString(); avm.title = v.Title; avm.context = v.Context; avm.vtype = v.vtype; avm.options = new List <VoteOptionsVM>(); for (int i = 0; i < v.Options.Count; i++) { avm.options.Add(new VoteOptionsVM() { id = v.Options[i].ID.ToString(), ActionType = null, OptinContext = v.Options[i].OptinContext, OptionTitle = v.Options[i].OptionTitle }); } return(Json(avm)); }
public ActionResult GetVoteOptCombo(string id) { OptComboMV t = new OptComboMV(); t.id = "ALL"; t.text = "ALL"; t.desc = "ALL"; List <OptComboMV> list = new List <OptComboMV>(); list.Add(t); VoteBL v = VoteBL.GetVote(id); for (int i = 0; i < v.Options.Count; i++) { t = new OptComboMV(); t.id = (i).ToString(); t.text = v.Options[i].OptionTitle; t.desc = v.Options[i].OptinContext; list.Add(t); } return(Json(list)); }