public void SendEmailGenericCommand()
        {
            mediator.Send(new SendEmailGenericCommand("Hello world!"));

            var lastSentMessage = this.emailSender.GetLastSentMessage(); ;
            Assert.Equal("Hello world!", lastSentMessage);
        }
예제 #2
0
        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);
        }
예제 #3
0
 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.
     }
 }
예제 #4
0
 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));
     }
 }
예제 #5
0
        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));
            }
        }
예제 #6
0
 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.
     }
 }
예제 #7
0
 public async Task <IProcessResult> Put(UpdateProductInfoCommand command) => await mediator.Send(command);
 public async Task <IProcessResult <int> > Post(CreateAttributeCommand command) => await mediator.Send(command);
예제 #9
0
 public void Post([FromBody] StockItemDto item)
 {
     _commandMediator.Send(CreateCommandForState(item));
 }