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