public ActionResult UserBind(string UserNo, string OpenID) { SysUser user = entity.SysUser.Where(p => p.UserName == UserNo).FirstOrDefault(); if (user == null) { ViewBag.Content = "为找到对应用户,请检查输入是否正确!"; return(View("Done")); } WXUSerBind wxuser = entity.WXUSerBind.Where(p => p.UserID == user.UserId).FirstOrDefault(); if (wxuser != null) { ViewBag.Content = "该用户已绑定,请勿重复绑定!"; return(View("Done")); } else { wxuser = new WXUSerBind(); wxuser.OpenID = OpenID; wxuser.UserID = user.UserId; entity.WXUSerBind.Add(wxuser); entity.SaveChanges(); } ViewBag.Content = "已完成绑定!"; return(View("Done")); }
public ActionResult Dispatch() { string code = Request.QueryString["code"]; try { wx_backdata <wx_oauth2token> oauth2token = wcc.GetOauth2AccessToken(code); WXUSerBind wxuser = entity.WXUSerBind.Where(p => p.OpenID == oauth2token.ResponseData.openid).FirstOrDefault(); if (wxuser == null) { return(new RedirectResult("/Home/UserBind?OpenID=" + oauth2token.ResponseData.openid)); } else { SysUser user = entity.SysUser.Where(p => p.UserId == wxuser.UserID).FirstOrDefault(); if (user == null) { ViewBag.Content = "用户不存在!"; return(View("Error")); } return(new RedirectResult("/Home/Index?UserID=" + user.UserId + "&UserName="******"&IsCustomer=No")); //WXSaleAfterMain main = entity.WXSaleAfterMain.Where(p => p.UserID == user.UserId && p.IsFinish != "是").FirstOrDefault(); //if (main != null && !string.IsNullOrEmpty(main.MoID) && main.IsXJR != "是") //{ // //MO mo = entity.MO.Where(p => p.MOId == main.MoID).FirstOrDefault(); // Ter_Customer_Com_Records tccr = entity.Ter_Customer_Com_Records.Where(p => p.MOName == main.MoID).FirstOrDefault(); // if(tccr != null && tccr.ProblemCompletion == "完成") // { // return new RedirectResult("/Home/QRCode?MainID=" + main.ID); // } // else // { // return new RedirectResult("/Home/WorkNote?MainID=" + main.ID); // } //} //else //{ // return new RedirectResult("/Home/Index?UserID=" + user.UserId + "&UserName="******"&IsCustomer=No"); //} } } catch (Exception e) { ViewBag.Content = e.ToString(); return(View("Error")); } }
public ActionResult WorkList() { string code = Request.QueryString["code"]; wx_backdata <wx_oauth2token> oauth2token = wcc.GetOauth2AccessToken(code); WXUSerBind wxuser = entity.WXUSerBind.Where(p => p.OpenID == oauth2token.ResponseData.openid).FirstOrDefault(); //WXUSerBind wxuser = entity.WXUSerBind.Where(p => p.ID == 3).FirstOrDefault(); if (wxuser == null) { return(new RedirectResult("/Home/UserBind?OpenID=" + oauth2token.ResponseData.openid)); } else { SysUser user = entity.SysUser.Where(p => p.UserId == wxuser.UserID).FirstOrDefault(); if (user == null) { ViewBag.Content = "用户不存在!"; return(View("Error")); } List <WXSaleAfterMain> mainList = new List <WXSaleAfterMain>(); if (user.UserId == "SUR1000007HM") { mainList = entity.WXSaleAfterMain.Where(p => p.IsFinish != "是").ToList(); } else { mainList = entity.WXSaleAfterMain.Where(p => p.UserID == user.UserId && p.IsFinish != "是").ToList(); } ViewBag.MainList = mainList; } return(View()); }