public void SendEmailGenericCommand() { mediator.Send(new SendEmailGenericCommand("Hello world!")); var lastSentMessage = this.emailSender.GetLastSentMessage(); ; Assert.Equal("Hello world!", lastSentMessage); }
public void CreateSampleAggregateCommand_NoResponse() { var aggregateId = Guid.NewGuid(); mediator.Send(new CreateSampleAggregateCommand(aggregateId, "Some name")); var aggregate = sampleAggregateRepository.Load(aggregateId); Assert.Equal("Some name", aggregate.Name); }
public IActionResult PublishAdvert(Guid id, [FromBody] StockItemDto data) { try { _command.Send(new PublishAdvertCommand(id, (int)data.Quantity)); return(new StatusCodeResult((int)HttpStatusCode.Accepted)); } catch (ItemNotFoundException) { return(NotFound()); } catch (InvalidOperationException ex) { return(BadRequest(ex.Message)); } catch { return(NotFound()); // Better a 404 than a potential hack vector. } }
public IActionResult Put(Guid id) { try { _commandMediator.Send(new StockDisposedCommand(id, GetUserId())); return(new StatusCodeResult((int)HttpStatusCode.Accepted)); } catch (System.Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult Put(Guid id, [FromBody] AdvertDto newState) { // Set the Id from the URI to the DTO to send on if (newState.Id == Guid.Empty) { newState.Id = id; } // Ensure the posting user is the advertiserId newState.AdvertiserId = GetUserId(); try { _commandMediator.Send(CreateCommandForState(newState)); return(Created($"/api/{GetControllerName()}/{id}", _queryMediator.Get(id))); } catch (System.Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult PostAdvert(Guid id, [FromBody] PostAdvertPayload data) { try { _command.Send(new PostAdvertCommand(id, GetUserId(), data.PublishType == "PublishAndAdd", data.StockQuantity)); return(new StatusCodeResult((int)HttpStatusCode.Accepted)); } catch (ItemNotFoundException) { return(NotFound()); } catch (InvalidOperationException ex) { return(BadRequest(ex.Message)); } catch { return(NotFound()); // Better a 404 than a potential hack vector. } }
public async Task <IProcessResult> Put(UpdateProductInfoCommand command) => await mediator.Send(command);
public async Task <IProcessResult <int> > Post(CreateAttributeCommand command) => await mediator.Send(command);
public void Post([FromBody] StockItemDto item) { _commandMediator.Send(CreateCommandForState(item)); }