コード例 #1
0
        public async Task <bool> Handle(SaveClientPropertyCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(false);
            }

            var savedClient = await _clientRepository.GetByClientId(request.ClientId);

            if (savedClient == null)
            {
                await Bus.RaiseEvent(new DomainNotification("Client", "Client not found"));

                return(false);
            }
            var property = request.ToEntiyTy(savedClient);


            _clientPropertyRepository.Add(property);

            if (await Commit())
            {
                await Bus.RaiseEvent(new NewClientPropertyEvent(request.Id, request.ClientId, property.Key, property.Value));

                return(true);
            }
            return(false);
        }
コード例 #2
0
        public async Task Handle(SaveClientPropertyCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return;
            }

            var savedClient = await _clientRepository.GetByClientId(request.ClientId);

            if (savedClient == null)
            {
                await Bus.RaiseEvent(new DomainNotification("1", "Client not found"));

                return;
            }

            var property = new ClientProperty()
            {
                Client = savedClient,
                Value  = request.Value,
                Key    = request.Key
            };

            _clientPropertyRepository.Add(property);

            if (Commit())
            {
                await Bus.RaiseEvent(new NewClientPropertyEvent(request.Id, request.ClientId, property.Key, property.Value));
            }
        }