Пример #1
0
        public async static Task <IHttpResponse> CreateAsync(
            [Api.Meta.Flows.WorkflowNewId]
            [Property(Name = AuthorizationIdPropertyName)]
            IRef <Authorization> authorizationRef,

            [Api.Meta.Flows.WorkflowParameter(Value = "{{AuthenticationMethod}}")]
            [Property(Name = MethodPropertyName)]
            IRef <Method> method,

            [Api.Meta.Flows.WorkflowParameter(Value = "http://example.com")]
            [Property(Name = LocationAuthorizationReturnPropertyName)]
            Uri locationAuthenticationReturn,

            [Resource] Authorization authorization,
            IAuthApplication application, IProvideUrl urlHelper,
            CreatedBodyResponse <Authorization> onCreated,
            AlreadyExistsResponse onAlreadyExists,
            ReferencedDocumentDoesNotExistsResponse <Method> onAuthenticationDoesNotExist)
        {
            authorization.accountIdMaybe = default;
            authorization.authorized     = false;

            return(await await Auth.Method.ById(method, application,
                                                async (method) =>
            {
                //var authorizationIdSecure = authentication.authenticationId;
                authorization.LocationAuthentication = await method.GetLoginUrlAsync(
                    application, urlHelper, authorizationRef.id);

                //throw new ArgumentNullException();
                return await authorization.StorageCreateAsync(
                    createdId => onCreated(authorization),
                    () => onAlreadyExists());
            },
                                                () => onAuthenticationDoesNotExist().AsTask()));
        }