public async Task <IActionResult> Create([FromBody] Card card)
        {
            var creation = new CreateCard(card);

            Console.WriteLine("Created card {0}.", card.Id);
            return(await _commands.Execute(creation, When <CardCreated> .ThenOk));
        }
        public async Task <IActionResult> ChangeEnrollment([FromServices] ICommandServer commands, string pages, Id dealerId)
        {
            if (!TryParsePages(pages, out var parsedPages))
            {
                return(new NotFoundResult());
            }

            return(await commands.Execute(
                       new ChangeEnrollment(dealerId, parsedPages),
                       When <DealerNotEnrolled> .ThenNotFound,
                       When <EnrollmentChanged> .ThenOk,
                       When <EnrollmentUnchanged> .ThenOk));
        }
Example #3
0
 public Task <IActionResult> StartImport([FromServices] ICommandServer commands) =>
 commands.Execute(
     new StartImport(),
     When <ImportStarted> .ThenOk,
     When <ImportAlreadyStarted> .ThenConflict);