Beispiel #1
0
        public async Task <IActionResult> PutLog([FromRoute] int id, [FromBody] Log log)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != log.LogId)
            {
                return(BadRequest());
            }

            _context.Entry(log).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LogExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        private async Task GetAuthTokensAsync(string code, string realmId)
        {
            oAuth2Client = new OAuth2Client(OAuth2Keys.ClientId, OAuth2Keys.ClientSecret, OAuth2Keys.RedirectUrl, OAuth2Keys.Environment);
            var tokenResponse = await oAuth2Client.GetBearerTokenAsync(code);

            OAuth2Keys.RealmId = realmId;
            Token token = _tokens.Token.FirstOrDefault(t => t.RealmId == realmId);

            if (token == null)
            {
                _tokens.Add(new Token {
                    RealmId = realmId, AccessToken = tokenResponse.AccessToken, RefreshToken = tokenResponse.RefreshToken
                });
                await _tokens.SaveChangesAsync();
            }
        }