public bool CreateOrUpdateOAuthUser(OAuthUser user) { try { var userInDb = GetOAuthUser(user.UserName); if (userInDb != null) { userInDb.Key = user.Key; userInDb.DataTimeKeyObtained = DateTime.UtcNow; userInDb.AdditionalData = user.AdditionalData; } else { _dbContext.OAuthUsers.Add(user); } _dbContext.SaveChanges(); return(true); } catch (Exception exception) { Logger.LogError("Error Create/Update User in DB", exception); return(false); } }
public bool CreateOrUpdateOAuthUser(OAuthUser user) { try { var userInDb = GetOAuthUser(user.UserName); if (userInDb != null) { userInDb.Key = user.Key; userInDb.DataTimeKeyObtained = DateTime.UtcNow; userInDb.AdditionalData = user.AdditionalData; } else { _dbContext.OAuthUsers.Add(user); } _dbContext.SaveChanges(); return true; } catch (Exception exception) { Logger.LogError("Error Create/Update User in DB", exception); return false; } }
private dynamic RefreshOAuthCode(OAuthUser user) { dynamic accessToken; try { accessToken = oauth.RefreshAccessToken(user.AdditionalData); } catch(Exception exception) { Logger.LogError("Uanble to refresh Auth Code. Resulted in error ", exception); return null; } try { new UserDataAccess().UpdateOAuthAccessCode(user.UserName, accessToken); return accessToken; } catch(Exception exception) { Logger.LogError("Uanble to update refreshed Auth Code in local DB. Resulted in error ", exception); return accessToken; } }