Exemple #1
0
        public async Task Execute()
        {
            var assigneesIds = await assigneesGetDbOperations.GetAllIds();

            if (assigneesIds.Any())
            {
                var incompleteGoalIds = await goalsGetDbOperations.GetIdsByState(GoalState.Incomplete);

                var incompleteGoals = await goalsGetDbOperations.Get(incompleteGoalIds);

                foreach (var goal in incompleteGoals)
                {
                    var selectedAssigneeId = assigneesIds[random.Next(0, assigneesIds.Length)];
                    await goalsWriteDbOperations.SetAssignee(goal.Id, selectedAssigneeId);

                    var assignUtcDateTime = dateTimeService.UtcNow;

                    await messageBus.Publish(new GoalAssignedEventV1
                    {
                        Id             = goal.Id,
                        AssigneeId     = selectedAssigneeId,
                        AssignDateTime = assignUtcDateTime
                    });
                }
            }
        }
Exemple #2
0
        public async Task Execute(string id)
        {
            await goalsWriteDbOperations.SetState(GoalState.Complete, id);

            var completeUtcDateTime = dateTimeService.UtcNow;
            var goal = await goalsGetDbOperations.Get(id);

            await messageBus.Publish(new GoalCompletedEventV1
            {
                Id               = id,
                AssigneeId       = goal.Assignee.Id,
                CompleteDateTime = completeUtcDateTime
            });
        }
Exemple #3
0
 public async Task <Goal> Query(string id)
 {
     return(await goalsGetDbOperations.Get(id));
 }