예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        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());
        }
예제 #5
0
        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));
        }
예제 #6
0
파일: Mutation.cs 프로젝트: llenroc/eSchool
        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);
        }
예제 #7
0
        public async Task <IActionResult> Post([FromBody] EnrollmentApplicationCommand command)
        {
            await _mediator.Send(command);

            return(Ok());
        }