public async Task <bool> Handle(DeleteNotificationDefPeopleAssignmentCommand request, CancellationToken cancellationToken)
        {
            var result = await _notificationDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownNotificationDefException(string.Format(Global.UnknownNotification, request.Id));
            }

            result.RemoveAssignment(request.AssignmentId);
            await _notificationDefCommandRepository.Update(result, cancellationToken);

            await _notificationDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Notification definition '{result.Name}', people assignment is removed");
            return(true);
        }
Exemplo n.º 2
0
        public async Task <bool> Handle(DeleteNotificationDefParameterCommand request, CancellationToken cancellationToken)
        {
            var result = await _notificationDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The notification definition '{request.Id}' doesn't exist");
                throw new UnknownNotificationDefException(string.Format(Global.UnknownNotification, request.Id));
            }

            result.DeleteOperationParameter(request.ParameterId);
            await _notificationDefCommandRepository.Update(result, cancellationToken);

            await _notificationDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Notification definition '{result.Name}', operation parameter '{request.ParameterId}' has been removed");
            return(true);
        }
Exemplo n.º 3
0
        public async Task <bool> Handle(DeleteNotificationDefPresentationElementCommand request, CancellationToken cancellationToken)
        {
            var result = await _notificationDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The notification definition '{request.Id}' doesn't exist");
                throw new UnknownNotificationException(string.Format(Global.UnknownNotification, request.Id));
            }

            result.DeletePresentationElement(request.Usage, request.Language);
            await _notificationDefCommandRepository.Update(result, cancellationToken);

            await _notificationDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Notification definition '{result.Name}', presentation element has been remvoed");
            return(true);
        }
Exemplo n.º 4
0
        public async Task <bool> Handle(AddNotificationDefPresentationParameterCommand request, CancellationToken cancellationToken)
        {
            var result = await _notificationDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The notification definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownNotification, request.Id));
            }

            if (request.PresentationParameter == null)
            {
                _logger.LogError($"The 'presentationParameter' parameter is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "parameter"));
            }

            result.AddPresentationParameter(request.PresentationParameter.ToDomain());
            await _notificationDefCommandRepository.Update(result, cancellationToken);

            await _notificationDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Notification definition '{result.Name}', presentation parameter '{request.PresentationParameter.Name}' has been added");
            return(true);
        }
        public async Task <bool> Handle(DeleteNotificationDefPresentationParameterCommand request, CancellationToken cancellationToken)
        {
            var result = await _notificationDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The notification definition '{request.Id}' doesn't exist");
                throw new UnknownNotificationDefException(string.Format(Global.UnknownNotification, request.Id));
            }

            if (string.IsNullOrWhiteSpace(request.Name))
            {
                _logger.LogError($"The 'name' parameter is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "name"));
            }

            result.DeletePresentationParameter(request.Name);
            await _notificationDefCommandRepository.Update(result, cancellationToken);

            await _notificationDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Notification definition '{result.AggregateId}', presentation parameter '{request.Name}' has been removed");
            return(true);
        }
Exemplo n.º 6
0
        public async Task <bool> Handle(UpdateNotificationDefInfoCommand request, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(request.Name))
            {
                _logger.LogError("the parameter 'name' is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "name"));
            }

            var result = await _notificationDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The notification definition '{request.Id}' doesn't exist");
                throw new UnknownNotificationDefException(string.Format(Global.UnknownNotification, request.Id));
            }

            var r = await _notificationDefQueryRepository.Search(new SearchNotificationDefParameter
            {
                Name = request.Name
            }, cancellationToken);

            r.Content = r.Content.Where(_ => _.AggregateId != request.Id).ToList();
            if (r != null && r.Content.Count() > 0)
            {
                _logger.LogError($"the notification '{request.Name}' already exists");
                throw new BadRequestException(string.Format(Global.NotificationDefExists, request.Name));
            }

            result.UpdateInfo(request.Name, request.Priority);
            await _notificationDefCommandRepository.Update(result, cancellationToken);

            await _notificationDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Notification definition '{result.Name}', information has been updated");
            return(true);
        }
Exemplo n.º 7
0
        public async Task <string> Handle(AddNotificationDefPeopleAssignmentCommand request, CancellationToken cancellationToken)
        {
            var result = await _notificationDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The notification definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownNotification, request.Id));
            }

            if (request.PeopleAssignment == null)
            {
                _logger.LogError($"The 'peopleAssignment' parameter is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "peopleAssignment"));
            }

            var id = result.Assign(request.PeopleAssignment.ToDomain());
            await _notificationDefCommandRepository.Update(result, cancellationToken);

            await _notificationDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Notification definition '{result.Name}', people is assigned");
            return(id);
        }