コード例 #1
0
        public async Task <IActionResult> UpdateAgentLogo([FromBody] UpdateAgentLogoCommand @command)
        {
            var result = await mediator.Send(@command);

            return(result ?
                   (IActionResult)Ok(result) :
                   (IActionResult)BadRequest());
        }
コード例 #2
0
        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);
        }