public async Task <bool> Handle(UpdateAgentCommand updateAgentCommand, CancellationToken cancellationToken) { var agent = await queryExecutor.Execute <GetAgentQuery, Agent>(new GetAgentQuery() { AgentId = updateAgentCommand.AggregateId }); agent = DataMapper.Map <Agent, UpdateAgentCommand>(updateAgentCommand); //agent.Firstname = updateAgentCommand.Firstname; //agent.Lastname = updateAgentCommand.Lastname; //agent.City = updateAgentCommand.City; //agent.Email = updateAgentCommand.Email; //agent.Phone = updateAgentCommand.Phone; //agent.Country = updateAgentCommand.Country; //agent.Address = updateAgentCommand.Address; //agent.Company = updateAgentCommand.Company; agent.UpdatedDate = DateTime.UtcNow; await agentRepository.Collection.ReplaceOneAsync( doc => doc.Id == agent.Id, agent, new UpdateOptions { IsUpsert = true }); return(true); }
public async Task <IActionResult> UpdateAgent([FromBody] UpdateAgentCommand updategentCommand) { var result = await mediator.Send(updategentCommand); return(result ? (IActionResult)Ok() : (IActionResult)BadRequest()); }