public async Task <TResult> CreateAsync <TResult>(Guid authenticationRequestId,
                                                          CredentialValidationMethodTypes method, AuthenticationActions action,
                                                          Guid actorLinkId, string token, Uri redirectUrl, Uri redirectLogoutUrl,
                                                          Func <TResult> onSuccess,
                                                          Func <TResult> onAlreadyExists)
        {
            var doc = new Documents.AuthenticationRequestDocument
            {
                Method = Enum.GetName(typeof(CredentialValidationMethodTypes), method),
                Action = Enum.GetName(typeof(AuthenticationActions), action),
                LinkedAuthenticationId = actorLinkId,
                Token       = token,
                RedirectUrl = redirectUrl.IsDefault() ?
                              default(string)
                    :
                              redirectUrl.AbsoluteUri,
                RedirectLogoutUrl = redirectLogoutUrl.IsDefault() ?
                                    default(string)
                    :
                                    redirectLogoutUrl.AbsoluteUri,
            };

            return(await this.repository.CreateAsync(authenticationRequestId, doc,
                                                     () => onSuccess(),
                                                     () => onAlreadyExists()));
        }
 public static Integration Convert(AuthenticationRequestDocument doc)
 {
     return(new EastFive.Azure.Integration
     {
         integrationId = doc.Id,
         method = doc.Method,
         parameters = doc.GetExtraParams(),
         authorizationId = doc.LinkedAuthenticationId.GetValueOrDefault(),
     });
 }
 private static AuthenticationRequest Convert(Documents.AuthenticationRequestDocument document)
 {
     return(new AuthenticationRequest
     {
         id = document.Id,
         method = (CredentialValidationMethodTypes)Enum.Parse(typeof(CredentialValidationMethodTypes), document.Method, true),
         action = (AuthenticationActions)Enum.Parse(typeof(AuthenticationActions), document.Action, true),
         authorizationId = document.LinkedAuthenticationId,
         token = document.Token,
         extraParams = document.GetExtraParams(),
         redirect = document.RedirectUrl.IsNullOrWhiteSpace()?
                    default(Uri)
             :
                    new Uri(document.RedirectUrl),
         redirectLogout = document.RedirectLogoutUrl.IsNullOrWhiteSpace() ?
                          default(Uri)
             :
                          new Uri(document.RedirectLogoutUrl),
         Deleted = document.Deleted,
     });
 }