public async Task <OneOf <NotFound, Success> > Execute(
            DocumentClient client,
            Configuration configuration,
            UpdateProviderType request)
        {
            var documentUri = UriFactory.CreateDocumentUri(
                configuration.DatabaseId,
                configuration.ProviderCollectionName,
                request.ProviderId.ToString());

            Provider provider;

            try
            {
                var response = await client.ReadDocumentAsync <Provider>(documentUri);

                provider = response.Document;
            }
            catch (DocumentClientException dex) when(dex.StatusCode == HttpStatusCode.NotFound)
            {
                return(new NotFound());
            }

            provider.ProviderType = request.ProviderType;

            await client.ReplaceDocumentAsync(documentUri, provider);

            return(new Success());
        }
예제 #2
0
        public OneOf <NotFound, Success> Execute(
            InMemoryDocumentStore inMemoryDocumentStore,
            UpdateProviderType request)
        {
            var provider = inMemoryDocumentStore.Providers.All.SingleOrDefault(p => p.Id == request.ProviderId);

            if (provider == null)
            {
                return(new NotFound());
            }

            provider.ProviderType = request.ProviderType;

            inMemoryDocumentStore.Providers.Save(provider);

            return(new Success());
        }