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