public async Task <IDictionary <Id, User> > Handle(SignInCommand request, CancellationToken cancellationToken) { var authData = await GoogleJsonWebSignature.ValidateAsync(request.Token); if (!authData.AudienceAsList.Contains(_secrets.ClientId)) { // generated with other client id throw new NotImplementedException(); } var user = new User( username: authData.Name, email: authData.Email, picture: authData.Picture ); var currentUserEntity = await _items .SingleOrDefaultAsync(x => x.Email == user.Email); if (currentUserEntity != null) { currentUserEntity = _uow.Update(currentUserEntity, e => e.FromModel(user)); } else { currentUserEntity = new UserEntity(); currentUserEntity.FromModel(user); currentUserEntity = _uow.Add(currentUserEntity); } await _uow.SaveChangesAsync(); return(new Dictionary <Id, User> { [currentUserEntity.Id] = user }); }