コード例 #1
0
        public ActionResult facebookJsLogin(string resid, string resemail, string resname)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            Session["Account"] = resid; //取得用戶ID
            Session["uname"] = resname; //取得用戶名稱
            Session["resAccount"] = "Facebook";//取得用戶來源
            Member m = new Member();
            MemberData md = new MemberData();
            if (Session["Account"] != null)
            {
                var memberData = md.Get().ToList().Where(a => a.uAccount == Session["Account"].ToString()).SingleOrDefault();
                if (memberData == null)
                {
                    m.uAccount = Session["Account"].ToString();
                    m.uName = resname;
                    m.wdate = DateTime.Now;
                    m.udate = DateTime.Now;
                    m.uPassWord = "******";
                    m.uphone = "";
                    m.memberID = DateTime.Now.ToString("yyyyMMdd") + (md.Get().Count + 1).ToString().PadLeft(3, '0');
                    m.isdel = 0;
                    m.sort = 5000;
                    m.FacebookId = resid;
                    m.GoogleId = "";
                    m.uemail = resemail ?? "";
                    md.Create(m);

                    dic.Add("Msg", "已成為會員");
                }
                else
                {
                    if (memberData.uemail == "" || memberData.uemail == null)
                    {
                        m.num = memberData.num;
                        m.uemail = resemail;
                        md.UpdateEmail(m);
                    }
                    dic.Add("Msg", "");
                }

            }

            dic.Add("success", true);
            return Json(dic);
        }