コード例 #1
0
        /// <summary>
        /// Creates new entry
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public UserInfo CreateNewUserToken(TokenInfo info)
        {
            var _userName = oauthFactory.GetOAuthTokenDao().getUser(info.access_token).username;

            var _userInfo = new UserInfo
            {
                AuthToken = info.access_token,
                RefreshToken = info.refresh_token,
                UserName = _userName,
                AuthDt = DateTime.Now
            };

            return factory.GetUserInfoDao().SaveUser(_userInfo);
        }
コード例 #2
0
        public UserInfo SaveUser(UserInfo info)
        {
            try
            {
                using (var dbCtx = new WeatherAppDbEntities())
                {
                    var firstOrDefault = dbCtx.UserInfo.FirstOrDefault(user => user.UserName == info.UserName);

                    if (firstOrDefault == null)
                    {
                        dbCtx.UserInfo.Add(info);
                        dbCtx.SaveChanges();

                        return info;
                    }

                    return firstOrDefault;
                }
            }
            catch (Exception e)
            {
                throw new DaoException("Error inserting  new user token info " + info, e);
            }
        }
コード例 #3
0
 /// <summary>
 /// Updates entry
 /// </summary>
 /// <param name="ui"></param>
 /// <returns></returns>
 public UserInfo UpdateToken(UserInfo ui)
 {
     using (var _ctx = new WeatherAppDbEntities())
     {
         var _userInfo = _ctx.UserInfo.FirstOrDefault(info => info.Id == ui.Id);
         _userInfo.AuthToken = ui.AuthToken;
         _ctx.SaveChanges();
         return _userInfo;
     }
 }