// // GET: /WeiXin/Score/ public ActionResult MyScore(string code, string state) { //string aaa = "code:" + code + " ; state:" + state; //return Content(aaa); OfficialAccount_BLL obll = new OfficialAccount_BLL(); Guid id = Guid.Parse(state); OfficialAccount off = obll.Get(a => a.AccountID == id); //return Content(off.AppID.Trim()+";"+ off.AppSecret.Trim()); OAuthAccessTokenResult result = OAuthApi.GetAccessToken(off.AppID.Trim(), off.AppSecret.Trim(), code); OAuthUserInfo info = OAuthApi.GetUserInfo(result.access_token, result.openid); //ViewBag.aaa = info.nickname; //ViewBag.bbb = info.openid; //return Content(info.nickname + info.openid); //return Content(result.openid); //string openid = "oqbOQs7w9UNUdksAEnd5zwIxUNCE"; Subscriber_BLL subbll = new Subscriber_BLL(); Subscriber mysub = subbll.Get(a => a.OpenID == info.openid); if (mysub != null) { //获取我的粉丝 List <Subscriber> fans = subbll.GetList(a => a.FromOpenID == info.openid).OrderBy(a => a.SubscribeTime).ToList(); ViewBag.FansList = fans; //获取的我的分数 if (mysub.Score != null) { ViewBag.MyScore = mysub.Score; } else { ViewBag.MyScore = 0; } } else { ViewBag.FansList = new List <Subscriber>(); ViewBag.MyScore = 0; } return(View()); }
public ActionResult Subscribe(string openid, int id = 1) { Subscriber_BLL bll = new Subscriber_BLL(); Subscriber parent = bll.Get(a => a.OpenID == openid); ViewBag.Parent = parent; List <Subscriber> childlist = bll.GetList(a => a.FromOpenID == openid).OrderByDescending(a => a.SubscribeTime).ToList(); AutoMapper.Mapper.CreateMap <Subscriber, Subscriber_ViewModel>(); List <Subscriber_ViewModel> vlist = AutoMapper.Mapper.Map <List <Subscriber_ViewModel> >(childlist); return(View(vlist.ToPagedList(id, 50))); }
public JsonResult GetSubscriberList(Guid accountid) { Subscriber_BLL bll = new Subscriber_BLL(); List <Subscriber> list = bll.GetList(a => a.AccountID == accountid && a.Longitude != null && a.Latitude != null).OrderByDescending(a => a.SubscribeTime).ToList(); AutoMapper.Mapper.CreateMap <Subscriber, Subscriber_ViewModel>(); List <Subscriber_ViewModel> vlist = AutoMapper.Mapper.Map <List <Subscriber_ViewModel> >(list); foreach (var item in vlist) { if (item.FromOpenID != null) { Subscriber sub = list.Where(a => a.AccountID == accountid && a.OpenID == item.FromOpenID).FirstOrDefault(); item.FromNickName = sub.NickName; item.FromHeadImgUrl = sub.HeadImgUrl; } } return(Json(vlist, JsonRequestBehavior.AllowGet)); }
public ActionResult MyScoreBySubscribeID(Guid SubscribeID) { Subscriber_BLL subbll = new Subscriber_BLL(); Subscriber mysub = subbll.Get(a => a.SubscribeID == SubscribeID); if (mysub != null) { //获取我的粉丝 List <Subscriber> fans = subbll.GetList(a => a.FromOpenID == mysub.OpenID).OrderBy(a => a.SubscribeTime).ToList(); ViewBag.FansList = fans; //获取的我的分数 if (mysub.Score != null) { ViewBag.MyScore = mysub.Score; } else { ViewBag.MyScore = 0; } } else { ViewBag.FansList = new List <Subscriber>(); ViewBag.MyScore = 0; } //Subscriber_ViewModel mysubvm = new Subscriber_ViewModel //{ // SubscribeID = mysub.SubscribeID, // NickName = info.nickname, // HeadImgUrl=info.headimgurl //}; return(View("MyScore")); }