示例#1
0
 public async Task Update(string id, User user)
 {
     ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));
     ServiceContract.RequireValidated(user, nameof(user));
     //TODO: Tutorial 3 - Publish an event here
     await _persistance.UpdateAsync(user.Id, user);
 }
        public async Task <Person> FindFirstOrDefaultByNameAsync(string name, CancellationToken token = default(CancellationToken))
        {
            ServiceContract.RequireNotNullOrWhitespace(name, nameof(name));
            var result = await _gdprCapability.PersonService.FindFirstOrDefaultByNameAsync(name, token);

            return(result);
        }
示例#3
0
        public async Task Update(string id, User user)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));
            ServiceContract.RequireValidated(user, nameof(user));

            await _persistance.UpdateAsync(user.Id, user);
        }
        public async Task <AccessToken> Token(AuthenticationCredentials credentials)
        {
            ServiceContract.RequireNotNull(credentials, nameof(credentials));
            ServiceContract.RequireNotNullOrWhitespace(credentials.ClientId, nameof(credentials.ClientId));
            ServiceContract.RequireNotNullOrWhitespace(credentials.ClientSecret, nameof(credentials.ClientSecret));

            return(await _authenticationService.GetTokenForTenant(credentials));
        }
        public async Task <IPersonProfile> ReadAsync(string id)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));
            var personProfile = await PersonProfilesFunctionality.ReadAsync(id);

            FulcrumAssert.IsNotNull(personProfile, $"{Namespace}: 56B82634-89A6-4EE4-969D-B7FFB4F9C016");
            FulcrumAssert.IsValidated(personProfile, $"{Namespace}: 56B82634-89A6-4EE4-969D-B7FFB4F9C016");
            return(personProfile);
        }
        public Task CatchAllEventsAsync(string entityName, string eventName, int majorVersion, dynamic eventBody)
        {
            ServiceContract.RequireNotNullOrWhitespace(entityName, nameof(entityName));
            ServiceContract.RequireNotNullOrWhitespace(eventName, nameof(eventName));
            ServiceContract.RequireGreaterThanOrEqualTo(1, majorVersion, nameof(majorVersion));
            ServiceContract.RequireNotNull(eventBody, nameof(eventBody));


            throw new FulcrumNotImplementedException($"The event {entityName}.{eventName} version {majorVersion} is not yet supported.");
        }
        public async Task PublishMockAsync(string entityName, string eventName, int majorVersion, int minorVersion, JObject content)
        {
            ServiceContract.RequireNotNullOrWhitespace(entityName, nameof(entityName));
            ServiceContract.RequireNotNullOrWhitespace(eventName, nameof(eventName));
            ServiceContract.RequireGreaterThanOrEqualTo(1, majorVersion, nameof(majorVersion));
            ServiceContract.RequireGreaterThanOrEqualTo(0, minorVersion, nameof(minorVersion));
            FulcrumAssert.IsTrue(FulcrumApplication.IsInDevelopment, $"This method can only be called in run time level Development. The run time level was {FulcrumApplication.Setup.RunTimeLevel}");
            var correlationId = new CorrelationIdValueProvider().CorrelationId;

            await new BusinessEvents(_tokenRefresher.GetServiceClient(), _subscribers).PublishAsync(entityName, eventName, majorVersion, minorVersion, content, correlationId);
        }
        public async Task <User> PutAsync(string id, User user)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));
            ServiceContract.RequireNotNull(user, nameof(user));
            ServiceContract.RequireValidated(user, nameof(user));

            await new BatchTranslate(_translateClient, "mobile-app", "customer-master")
            .Add("user.type", user.Type, translatedValue => user.Type = translatedValue)
            .ExecuteAsync();

            throw new FulcrumNotImplementedException("Method PUT /Users/{id} is not yet implemented - Part of tutorial 1");
        }
        public async Task <Product> GetProduct(string id)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));

            var bllProduct = await _productFunctionality.ReadAsync(id);

            var result = FromBll(bllProduct);

            FulcrumAssert.IsNotNull(result, nameof(result));
            FulcrumAssert.IsValidated(result, $"{Namespace}: 41042A82-2D71-427F-BBBF-9CDC7545E590");
            return(result);
        }
        public async Task <Product> DeleteProduct(string id)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));

            var bllProduct = await _productFunctionality.Delete(id);

            var result = FromBll(bllProduct);

            FulcrumAssert.IsNotNull(result, nameof(result));
            FulcrumAssert.IsValidated(result, $"{Namespace}: 8278948E-33CE-4B27-82B1-83BD26CF3788");

            return(result);
        }
        public async Task <User> GetAsync(string id)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));

            /* Code for translating the user type to approperiate context
             * The call to translate maps a concept (the 'kind' of value to be translated) to
             * a clients context (each client is assigned a context which decides the range to translate from/to
             * See GetAllAsync // wiki for more insight in translation.
             */

            await Task.Yield(); //Remove this line

            throw new FulcrumNotImplementedException("Method GET /Users/{id} is not yet implemented - Part of tutorial 1");
        }
示例#12
0
        public async Task <HealthResponse> ServiceHealthAsync(string organization, string environment)
        {
            ServiceContract.RequireNotNullOrWhitespace(organization, nameof(organization));
            ServiceContract.RequireNotNullOrWhitespace(environment, nameof(environment));
            var tenant = new Tenant(organization, environment);

            //******Example to check health of resources******//
            //******Expected return type is a HealthResponse or something castable to a HealthResponse******//

            //var aggregator = new ResourceHealthAggregator(tenant, "ExampleAdapter");
            //await aggregator.AddResourceHealthAsync("Database", _logicLayer);
            //var result = aggregator.GetAggregatedHealthResponse();
            //return result;
            return(new HealthResponse());
        }
示例#13
0
        public void WhitespaceString()
        {
            const string parameterName = "parameterName";

            try
            {
                string whitespaceString = "     \t";
                // ReSharper disable once ExpressionIsAlwaysNull
                ServiceContract.RequireNotNullOrWhitespace(whitespaceString, parameterName);
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Fail("An exception should have been thrown");
            }
            catch (FulcrumServiceContractException fulcrumException)
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(fulcrumException.TechnicalMessage.Contains(parameterName));
            }
            catch (Exception e)
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Fail($"Expected a specific FulcrumException but got {e.GetType().FullName}.");
            }
        }
示例#14
0
        public User DeleteOne(string id)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));

            throw new FulcrumNotImplementedException();
        }
        public User DeleteOne(string id)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));

            throw new FulcrumNotImplementedException("Method DELETE /Users/{ id } is not yet implemented - Part of tutorial 1");
        }
 public async Task DeleteAsync(string id)
 {
     ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));
     await PersonProfilesFunctionality.DeleteAsync(id);
 }
        public async Task <User> Read(string id)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));

            return(await _persistance.ReadAsync(id));
        }
        public async Task Delete(string id)
        {
            ServiceContract.RequireNotNullOrWhitespace(id, nameof(id));

            await _persistance.DeleteAsync(id);
        }