Beispiel #1
0
            public static Task NewTaskFrom(string title, string descrition, DateTime?dueDate = null, Priority priority = Priority.Normal)
            {
                var task    = new Task();
                var created = new TaskCreatedEvent(Guid.NewGuid(), title, descrition, dueDate, priority);

                task.RaiseEvent(created); return(task);
            }
        private TaskAggregateRoot(Guid taskId, string name, Guid runningNumberId,
                                  Guid categoryId, Guid?previewImageFileId, int storypoints = 0) : this()
        {
            var creationEvent = new TaskCreatedEvent(taskId, name, runningNumberId, categoryId,
                                                     previewImageFileId, DateTime.Now, storypoints);

            this.RaiseEvent(creationEvent);
        }
 private void Apply(TaskCreatedEvent obj)
 {
     this.AggregateId        = obj.AggregateId;
     this.Name               = obj.Name;
     this.CategoryId         = obj.CategoryId;
     this.PreviewImageFileId = obj.PreviewImageFileId;
     this.Storypoints        = obj.StoryPoints;
 }
Beispiel #4
0
        public async System.Threading.Tasks.Task Handle(TaskCreatedEvent message)
        {
            var t = new OTask();

            t.Id             = message.TaskId;
            t.DateOfCreation = message.DateOfCreation;
            t.IsCompleted    = false;
            t.Name           = message.TaskName;
            t.UserId         = message.UserId;

            ActiveDbContext.Tasks.Add(t);
            await ActiveDbContext.SaveChangesAsync();
        }
        public async Task HandleAsync(CreateTaskCommand command, ICorrelationContext context)
        {
            var task = new Domain.Task(command.Id, command.Title, command.Description, command.AssignedTo, command.PlannedStartDate,
                                       command.PlannedEndDate, command.ActualStartDate, command.ActualEndDate, command.Status, command.Priority,
                                       command.AttachmentPath, command.Owner, command.EntryDate);

            var taskCreated = new TaskCreatedEvent(command.Id, command.Title, command.Description, command.AssignedTo, command.PlannedStartDate,
                                                   command.PlannedEndDate, command.ActualStartDate, command.ActualEndDate, command.Status, command.Priority,
                                                   command.AttachmentPath, command.Owner, command.EntryDate);

            await _taskRepository.AddAsync(task);

            await _publisher.PublishAsync(taskCreated, context);

            // publish the event to bus
            // do some logging
        }
Beispiel #6
0
            public static Task Create(Guid userId, string name)
            {
                if (userId == Guid.Empty)
                {
                    throw new ArgumentException("Invalid user Id", nameof(userId));
                }
                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentException("A task must have a name.", nameof(name));
                }

                var e = new TaskCreatedEvent()
                {
                    TaskId         = Guid.NewGuid(),
                    DateOfCreation = DateTime.Now,
                    TaskName       = name,
                    UserId         = userId
                };
                var task = new Task();

                task.RaiseEvent(e);
                return(task);
            }
 public async Task HandleTaskCreatedEvent(TaskCreatedEvent taskCreatedEvent)
 {
     // Here you can do whatever you need with this event, you can propagate the data using a queue, calling another API or sending a notification or whatever
     // With this scenario, you are building a event driven architecture with microservices and DDD
 }