public async Task <IActionResult> GetWhoAmI() { return(await Task.FromResult(Ok(new { ObjectId = _userId.GetObjectId(), Name = _userId.GetName(), Email = _userId.GetEmailAddress() }))); }
public async Task <IActionResult> GetPerson() { var objectId = _userId.GetObjectId(); var emailAddress = _userId.GetEmailAddress(); var name = _userId.GetName(); var query = await _querySource .V <Person>() .Where(p => p.Oid == objectId) .FirstOrDefaultAsync(); if (query == null) { Log.Information("Adding New Person"); var newPerson = await _querySource .AddV(new Person { Oid = objectId, Email = emailAddress, Name = name }) .FirstOrDefaultAsync(); return(Ok(newPerson)); } if (query.Email != emailAddress || query.Name != name) { Log.Information("Updating Existing Person"); query.Email = emailAddress; query.Name = name; var updatedPerson = await _querySource .ReplaceV(query) .FirstOrDefaultAsync(); return(Ok(updatedPerson)); } Log.Information("Returning Existing Person"); return(Ok(query)); }