public async Task OnStatusChanged(InitiativeStatusChangedEventArgs initiativeStatusDescriptionChangedEventArgs, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(initiativeStatusDescriptionChangedEventArgs);
            EnsureArg.IsNotNull(initiativeStatusDescriptionChangedEventArgs.Initiative);


            var initiative = initiativeStatusDescriptionChangedEventArgs.Initiative;

            _logger.Information("Initiative {InitiativeId} has had its status changed to {Status}, firing webhooks...", initiative.Id, initiative.Status.ToString());

            InitiativeStatusHistory lastStep = initiative.StatusHistories?.OrderByDescending(x => x.StatusEntryDateUtc).FirstOrDefault();
            DateTime expectedExitDateAlberta = lastStep == null || !lastStep.ExpectedExitDateUtc.HasValue
                ? DateTime.MinValue : TimeZoneInfo.ConvertTimeFromUtc(lastStep.ExpectedExitDateUtc.Value, AlbertaTimeZone);
            var nowDateAlberta = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, AlbertaTimeZone);


            string expectedCompletionDateString = expectedExitDateAlberta == DateTime.MinValue
                ? string.Empty
                : "by " + expectedExitDateAlberta.ToStringRelativeToNow(nowDateAlberta);

            await FireWebHooksAsync(initiative,
                                    WebhookEvents.StatusChanged,
                                    data : values =>
            {
                values["Status"]       = initiative.Status.ToString();
                values["ExpectedTime"] = expectedCompletionDateString;
            },
                                    cancellationToken : cancellationToken);
        }
Exemplo n.º 2
0
 public Task SendInitiativeStatusChangedAsync(InitiativeStatusChangedEventArgs initiativeCreatedEventArgs)
 {
     // do nothing
     return(Task.CompletedTask);
 }