예제 #1
0
        //// GET api/values/5
        //public string Get(int id)
        //{
        //    return "value";
        //}

        // POST api/values
        public void Post([FromBody] CreatePolicyCommand command)
        {
            var insurancePolicy = new InsurancePolicy(this.ServiceLocator);

            //Create the policy. This is the only way you can create a policy
            insurancePolicy.CreatePolicy(command);
        }
예제 #2
0
        public async Task <ActionResult <PolicyDTO> > Post([FromBody] CreatePolicyCommand data)
        {
            Guid policyId = await this.Mediator.Send(data);

            PolicyDTO policy = await this.Mediator.Send(new GetPolicyDetailsQuery(policyId));

            return(this.CreatedAtRoute("GetPolicyDetails", new { policyNumber = policyId }, policy));
        }
예제 #3
0
        public void CreatePolicy(CreatePolicyCommand createPolicyCommand)
        {
            var @event = new PolicyCreatedEvent()
            {
                PolicyNumber = createPolicyCommand.PolicyNumber,
                MessageId    = Guid.NewGuid(),
                Coverage     = createPolicyCommand.Coverage
            };

            this.ApplyEvent(@event);
            this.PolicyData.CreateStreamAndFirstEvent(@event);
        }
예제 #4
0
        public async Task <CreatePolicyResponse> CreatePolicyAsync(CreatePolicyCommand command)
        {
            var policy = new Domain.Policy(command.PolicyDateFrom, command.PolicyDateTo);

            _policyContext.Policy.Add(policy);

            var insured = new Insured(command.InsuredFirstName, command.InsuredLastName, command.InsuredNumber);

            policy.AttachInsured(insured);
            policy.AddProducts(command.ProductsCodes.ToList());

            await _policyContext.SaveChangesAsync();

            return(new CreatePolicyResponse {
                PolicyId = policy.PolicyId
            });
        }
        public async Task CanCreateAndDeletePolicy()
        {
            //Arrange
            var facade = _fixture.Facade;

            var policyName = Guid.NewGuid().ToString();
            var command    = new CreatePolicyCommand(policyName, "{\"Version\": \"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"s3: ListAllMyBuckets\",\"Resource\":\"arn:aws:s3:::*\"}]}");

            //Act
            var result = await facade.Execute(command);

            var result2 = await facade.Execute(new DeletePolicyCommand(result.Arn));

            //Assert
            Assert.NotNull(result);
            Assert.Equal(policyName, result.PolicyName);
            Assert.True(result2.IsCompletedSuccessfully);
        }
예제 #6
0
        public async Task <ActionResult> Post([FromBody] CreatePolicyCommand cmd)
        {
            var result = await bus.Send(cmd);

            return(new JsonResult(result));
        }
예제 #7
0
        public async Task <IActionResult> CreatePolicy([FromBody] CreatePolicyCommand cmd)
        {
            var result = await mediator.Send(cmd);

            return(Ok(result));
        }
예제 #8
0
        public async Task <CreatePolicyResult> CreatePolicyAsync(CreatePolicyCommand command)
        {
            var policyResult = await _mediator.Send(command);

            return(policyResult);
        }
 public async Task <ActionResult> Post([FromBody] CreatePolicyCommand command)
 {
     return(new JsonResult(await _policyApplicationService.CreatePolicyAsync(command)));
 }
예제 #10
0
 public async Task <IActionResult> Post(CreatePolicyCommand command)
 {
     return(await PublishAsync(command));
 }