コード例 #1
0
        private void SaveTwitterInfo(Profile model)
        {
            ServiceStack.Data.IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["db"].ConnectionString, MySqlDialect.Provider);
            using (IDbConnection db = dbFactory.Open())
            {
                //Check user Exits
                var alreadyExist = db.Select<Profile>().Where(u => u.UserId == model.UserId).FirstOrDefault();
                if (alreadyExist != null)
                {
                    return;
                }
                db.Insert<Profile>(model);

            }
        }
コード例 #2
0
        private void SaveGoogleUserInfo(dynamic obj)
        {
            try
            {
                if (obj["access_token"] != null)
                {
                    var userInfo = GetUserAdditionalInfo(obj["access_token"]);
                    Profile model = new Profile();
                    model.AccessToken = obj["access_token"];
                    model.RefreshToken = obj["refresh_token"];
                    model.ProfileTypeID = 2;
                    model.UserId = userInfo["id"];
                    model.Username = userInfo["name"];
                    ServiceStack.Data.IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["db"].ConnectionString, MySqlDialect.Provider);
                    using (IDbConnection db = dbFactory.Open())
                    {
                        //Check user Exits
                        var alreadyExist = db.Select<Profile>().Where(u => u.UserId == model.UserId).FirstOrDefault();
                        if (alreadyExist != null)
                        {
                            return;
                        }
                        db.Insert<Profile>(model);

                    }
                }
            }
            catch (Exception)
            {

                throw;
            }
        }