public async Task <ResourcesProjection> Find(Guid id)
        {
            var query = new GetResourcesQuery();

            var result = await _resourceStorageHandler.Ask <List <ResourcesProjection> >(query);

            var readModel = result.SingleOrDefault(x => x.Id == id);

            return(readModel);
        }
Ejemplo n.º 2
0
        public async Task <OperationsReadModel> Find(Guid operationId)
        {
            var query = new GetOperationsQuery();

            var result = await _operationStorageHandler.Ask <List <OperationsReadModel> >(query);

            var readModel = result.SingleOrDefault(x => x.Id == operationId);

            return(readModel);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> IssueGiftCard([FromBody] GiftCardInputModel model)
        {
            var aggregateId = GiftCardId.New;

            var command = new IssueCommand(aggregateId, model.Credits);

            var executionResult = await _aggregateManager.Ask <ExecutionResult>(command);

            if (executionResult.IsSuccess)
            {
                return(Accepted(new { Id = aggregateId.GetGuid() }));
            }

            return(BadRequest(executionResult.ToString()));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PostCar()
        {
            var aggregateId = CarId.New;

            var command = new CreateCarCommand(aggregateId);

            var executionResult = await _aggregateManager.Ask <ExecutionResult>(command);

            if (executionResult.IsSuccess)
            {
                return(Accepted(new { Id = aggregateId.GetGuid() }));
            }

            return(BadRequest(executionResult.ToString()));
        }
Ejemplo n.º 5
0
        public async Task <string> Get()
        {
            return(await _response.Ask <string>(string.Empty));

            //var responseref = Response<string>.CreateResponse();

            // _actorSystem.EventStream.Publish(responseref);

            //await Task.Delay(2000);

            //return await responseref.GetResponseAsync();
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> PostResource()
        {
            var resourceId = ResourceId.New;
            var id         = resourceId.GetGuid();
            var command    = new CreateResourceCommand(resourceId);

            var result = await _resourceManager.Ask <IExecutionResult>(command);

            if (result.IsSuccess)
            {
                var location        = new Uri($"{GetAbsoluteUri(HttpContext)}/api/operations/{id}");
                var contentLocation = new Uri($"{GetAbsoluteUri(HttpContext)}/api/resources/{id}");
                HttpContext.Response.Headers.Add("Location", location.ToString());
                HttpContext.Response.Headers.Add("Content-Location", contentLocation.ToString());

                return(Accepted(new ResourceResponseModel(id, id)));
            }
            else
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 7
0
        public async Task <ActionResult <string> > Get(string id)
        {
            var member = await _gateway.Ask <MemberStateResponse> (new GetMemberState (id));

            return(Ok(member));
        }