async Task <bool> IAzureTableManager.UpdateRow(LametricEntity row) { var table = await _getTableObject(); TableOperation insertOperation = TableOperation.InsertOrReplace(row); await table.ExecuteAsync(insertOperation); return(true); }
public async Task <IActionResult> Oauth2token([FromQuery] string code, [FromQuery] string state) { if (!string.IsNullOrEmpty(code) && !string.IsNullOrEmpty(state)) { var token = await _visualStudioEndpoints.GetAccessCodeAsync(code); if (!string.IsNullOrEmpty(token.Error) && !string.IsNullOrEmpty(token.message)) { return(this.RedirectToAction("Index", "Home", token)); } _visualStudioEndpoints.access_token = token.access_token; var profile = await _visualStudioEndpoints.GetUserProfileAsync(); if (!string.IsNullOrEmpty(profile.Error) && !string.IsNullOrEmpty(token.message)) { return(this.RedirectToAction("Index", "Home", profile)); } var lametricEntity = await _azureTableManager.GetRow(profile.emailAddress); if (lametricEntity == null) { lametricEntity = new LametricEntity(profile.emailAddress); lametricEntity.Email = profile.emailAddress; lametricEntity.VSO_Url = ""; } lametricEntity.AccessToken = token.access_token; lametricEntity.RefreshToken = token.refresh_token; await _azureTableManager.UpdateRow(lametricEntity); Response.Cookies.Append("lametric-auth-accesstoken", token.access_token); Response.Cookies.Append("lametric-email", profile.emailAddress); Response.Cookies.Append("lametric-name", profile.displayName); Response.Cookies.Append("lametric-vso-url", lametricEntity.VSO_Url); return(this.RedirectToAction("Index", "Home")); } return(this.RedirectToAction("Index", "Home")); }