public async Task <Enrollment> AddEnrollmentAsync( EnrollmentApplicationCommand input, [Service] EnrollingContext context, CancellationToken cancellationToken) { if (input == null) { throw new ArgumentNullException(nameof(input)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } var enrollment = new Enrollment( input.Name, input.Email, input.Mobile); await context.Enrollments.AddAsync(enrollment, cancellationToken) .ConfigureAwait(false); await context.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); return(enrollment); }
public async Task <IActionResult> Post( [FromBody] EnrollmentApplicationCommand command, CancellationToken cancellationToken) { var enrollment = await _sender.Send(command, cancellationToken) .ConfigureAwait(false); return(CreatedAtAction(nameof(GetById), new { id = enrollment.Id }, enrollment)); }
public async Task <IActionResult> Post( [FromBody] EnrollmentApplicationCommand command, CancellationToken cancellationToken) { await _mediator.Send(command, cancellationToken) .ConfigureAwait(false); return(Ok()); }
public async Task <IActionResult> Post([FromBody] EnrollmentApplicationCommand command) { _logger.LogInformation( "Sending command: {CommandName} - ({@Command})", command.GetType().Name, command); await _mediator.Send(command); return(Ok()); }
public async Task <Enrollment> CreateEnrollmentAsync( EnrollmentApplicationCommand enrollment, [Service] IEnrollingServiceClient client, CancellationToken cancellationToken = default) { if (client == null) { throw new ArgumentNullException(nameof(client)); } return(await client.CreateAsync(enrollment, cancellationToken).ConfigureAwait(false)); }
public async Task <Enrollment> AddEnrollmentAsync( EnrollmentApplicationCommand input, [Service] EnrollingContext context) { var enrollment = new Enrollment( input.Name, input.Email, input.Mobile); await context.Enrollments.AddAsync(enrollment); await context.SaveChangesAsync(); return(enrollment); }
public async Task <IActionResult> Post([FromBody] EnrollmentApplicationCommand command) { await _mediator.Send(command); return(Ok()); }