public async Task <IActionResult> MarkAgentAsLaunched([FromBody] MarkAgentAsLaunched @command) { var result = await mediator.Send(@command); return(result ? (IActionResult)Ok(result) : (IActionResult)BadRequest()); }
public async Task <bool> Handle(MarkAgentAsLaunched @command, CancellationToken cancellationToken) { var agent = await queryExecutor.Execute <GetAgentQuery, Agent>(new GetAgentQuery() { AgentId = @command.AggregateId }); agent.MarkAsLunched(); var filter = Builders <Agent> .Filter.Eq("Id", agent.Id); var update = Builders <Agent> .Update .Set("IsLaunched", true) .CurrentDate("UpdatedDate"); await agentRepository.Collection .UpdateOneAsync(filter, update, new UpdateOptions { IsUpsert = true }); await mediator.DispatchDomainEventsAsync(agent); return(true); }