//// 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); }
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)); }
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); }
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); }
public async Task <ActionResult> Post([FromBody] CreatePolicyCommand cmd) { var result = await bus.Send(cmd); return(new JsonResult(result)); }
public async Task <IActionResult> CreatePolicy([FromBody] CreatePolicyCommand cmd) { var result = await mediator.Send(cmd); return(Ok(result)); }
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))); }
public async Task <IActionResult> Post(CreatePolicyCommand command) { return(await PublishAsync(command)); }