Esempio n. 1
0
        public async Task <string> Handle(CreateNotificationInstanceCommand request, CancellationToken cancellationToken)
        {
            var notificationDef = await _notificationDefQueryRepository.Get(request.NotificationId, cancellationToken);

            if (notificationDef == null)
            {
                throw new UnknownNotificationException(string.Format(Global.UnknownNotification, request.NotificationId));
            }

            var operationParameters = request.Parameters == null ? new Dictionary <string, string>() : request.Parameters;
            var parameters          = _parameterParser.ParseOperationParameters(notificationDef.InputParameters, operationParameters);

            _logger.LogInformation($"Create notification '{notificationDef.Name}'");
            var presentationElt = _parameterParser.ParsePresentationElements(notificationDef.PresentationElements,
                                                                             notificationDef.PresentationParameters,
                                                                             parameters);
            var assignmentInstance = _parameterParser.ParsePeopleAssignments(
                notificationDef.PeopleAssignments,
                parameters);
            var id = Guid.NewGuid().ToString();
            var notificationInstance = NotificationInstanceAggregate.New(id,
                                                                         notificationDef.Priority,
                                                                         notificationDef.Name,
                                                                         parameters,
                                                                         presentationElt,
                                                                         assignmentInstance,
                                                                         notificationDef.Rendering);
            await _notificationInstanceCommandRepository.Add(notificationInstance, cancellationToken);

            await _notificationInstanceCommandRepository.SaveChanges(cancellationToken);

            return(notificationInstance.AggregateId);
        }
Esempio n. 2
0
 public static NotificationDetailsResult ToDto(
     NotificationInstanceAggregate notificationInstance,
     Localization.Translation name,
     Localization.Translation subject)
 {
     return(new NotificationDetailsResult
     {
         Id = notificationInstance.AggregateId,
         Name = notificationInstance.NotificationName,
         Priority = notificationInstance.Priority,
         CreatedTime = notificationInstance.CreateDateTime,
         LastModifiedTime = notificationInstance.UpdateDateTime,
         PresentationName = name?.Value,
         PresentationSubject = subject?.Value,
         Status = Enum.GetName(typeof(NotificationInstanceStatus), notificationInstance.Status)
     });
 }
 public NotificationInstanceExpressionContext(NotificationInstanceAggregate notificationContext) : base(notificationContext.OperationParameters)
 {
 }
 public Task <bool> Add(NotificationInstanceAggregate notification, CancellationToken token)
 {
     _notifications.Add((NotificationInstanceAggregate)notification.Clone());
     return(Task.FromResult(true));
 }
 public Task <bool> Add(NotificationInstanceAggregate notification, CancellationToken token)
 {
     _dbContext.Add(notification);
     return(Task.FromResult(true));
 }