public async Task <VisitorResponse> Update([FromBody] UpdateVisitorRequest request) { var cmd = new UpdateVisitorCommand(request); await _cqrsDispatcher.ExecuteCommand(cmd, null, new CancellationToken()); var query = new GetVisitorQuery(cmd.Id); var response = await _cqrsDispatcher.ExecuteQuery <GetVisitorQuery, VisitorResponse>(query, null, new CancellationToken()); return(response); }
public Visitor(UpdateVisitorCommand cmd) { if (cmd == null) { throw new ArgumentNullException(nameof(cmd), "Команда не передана"); } Id = new ObjectId(cmd.Id); FirstName = cmd.FirstName; LastName = cmd.LastName; MiddleName = cmd.MiddleName; }
public async Task Execute(UpdateVisitorCommand cmd, CqrsContext ctx, CancellationToken cancellationToken = new CancellationToken()) { var visitor = new Visitor(cmd); await _visitorsRepository.Update(visitor); }