Пример #1
0
 public static Task <IHttpResponse> HttpDeleteAsync <TResource>(
     this IRef <TResource> resourceRef,
     NoContentResponse onDeleted,
     NotFoundResponse onNotFound)
     where TResource : IReferenceable
 {
     return(resourceRef.StorageDeleteAsync(
                onDeleted: (discard) => onDeleted(),
                () => onNotFound()));
 }
Пример #2
0
 public static Task <TResult> DeleteInternalAsync <TResult>(
     IRef <XIntegration> integrationRef,
     Func <TResult> onDeleted,
     Func <TResult> onNotFound)
 {
     return(integrationRef.StorageDeleteAsync(
                onDeleted: (discard) =>
     {
         return onDeleted();
     },
                () => onNotFound()));
 }
 public static Task <TResult> DeleteInternalAsync <TResult>(
     IRef <XIntegration> integrationRef, Api.Azure.AzureApplication application,
     Func <TResult> onDeleted,
     Func <TResult> onNotFound)
 {
     return(integrationRef.StorageDeleteAsync(
                () =>
     {
         return onDeleted();
     },
                () => onNotFound()));
 }
Пример #4
0
 public static Task <IHttpResponse> DeleteAsync(
     [UpdateId(Name = SessionIdPropertyName)] IRef <Session> sessionRef,
     NoContentResponse onDeleted,
     NotFoundResponse onNotFound)
 {
     return(sessionRef.StorageDeleteAsync(
                onDeleted: (discard) =>
     {
         return onDeleted();
     },
                onNotFound: () => onNotFound()));
 }
Пример #5
0
 public static Task <HttpResponseMessage> DeleteAsync(
     [UpdateId(Name = SessionIdPropertyName)] IRef <Session> sessionRef,
     Api.Azure.AzureApplication application,
     NoContentResponse onDeleted,
     NotFoundResponse onNotFound)
 {
     return(sessionRef.StorageDeleteAsync(
                () =>
     {
         return onDeleted();
     },
                onNotFound: () => onNotFound()));
 }
Пример #6
0
        public static async Task <TResult> DeleteInternalAsync <TResult>(
            IRef <Integration> integrationRef, Api.Azure.AzureApplication application,
            Func <TResult> onDeleted,
            Func <TResult> onNotFound)
        {
            var integrationMaybe = await integrationRef.StorageGetAsync(i => i, () => default(Integration?));

            if (!integrationMaybe.HasValue)
            {
                return(onNotFound());
            }

            var integration = integrationMaybe.Value;

            return(await await integrationRef.StorageDeleteAsync(
                       onDeleted: async(discard) =>
            {
                if (integration.authorization.HasValue)
                {
                    var authorizationId = integration.authorization.id.Value;
                    var authorizationLookupRef = authorizationId.AsRef <AuthorizationIntegrationLookup>();
                    await authorizationLookupRef.StorageDeleteAsync(
                        onDeleted: (discard) => true);
                }
                var accountIntegrationRef = integration.accountId.AsRef <AccountIntegrationLookup>();
                await accountIntegrationRef.StorageUpdateAsync(
                    async(accountLookup, saveAsync) =>
                {
                    accountLookup.integrationRefs = accountLookup.integrationRefs.ids
                                                    .Where(id => id != integration.id)
                                                    .AsRefs <Integration>();
                    await saveAsync(accountLookup);
                    return true;
                });
                return onDeleted();
            },
                       () => onNotFound().AsTask()));
        }