コード例 #1
0
        /// <summary>
        /// remove client property command handler
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <bool> Handle(RemoveClientPropertyCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(false);
            }

            var client = await _clientRepository.GetClientAsync(request.ClientId);

            if (client == null)
            {
                await _bus.RaiseEvent(new DomainNotification("key_not_found", $"Client named {request.ClientId} not found"));

                return(false);
            }

            var property = await _clientPropertyRepository.FindByIdAsync(request.Id);

            if (property != null)
            {
                await _clientPropertyRepository.RemoveAsync(property);

                return(Commit());
            }

            return(true);
        }
コード例 #2
0
 public async Task RemovePropertiesAsync(string clientId, int id)
 {
     var command = new RemoveClientPropertyCommand(clientId, id);
     await _bus.SendCommand(command);
 }