private async Task UpdatedAlert(int alertId, string alertMessage, string alertName, bool alertIsSendingEmail, int requestId, string emailManger, DateTime date, string link) { //remove all alerts and emails by request and alerttype await _alertNotificationManager.RemoveByRequestIdAndAlertTypeAsync(requestId, alertId); await _emailNotificationManager.RemoveByRequestIdAndAlertTypeAsync(requestId, alertId); var periods = await _alertTypeManager.GetAlertTypePeriodTimesByAlertType(alertId); foreach (var period in periods) { var dateAlert = period.PeriodTime.GetDateTimeFrom(date); if (dateAlert < DateTime.UtcNow) { continue; } var text = $"<b>{alertMessage} - {period.PeriodTime.Name}.</b><br/>Request - <b>{link}</b>"; await _alertNotificationManager.CreateNotificationAlertAsync(text, emailManger, dateAlert, requestId, alertId); if (alertIsSendingEmail) { var subject = $"QFLOW : {alertName}"; await _emailNotificationManager.CreateNotificationAsync(new[] { emailManger }, subject, text, null, dateAlert, requestId, alertId); } } }
private async Task <AlertTypeViewModel> BuildAlertTypeViewModel(AlertType alert) { return(new AlertTypeViewModel { Id = alert.Id, Name = alert.Name, Message = alert.Message, IsSendingEmail = alert.IsSendingEmail, NotifyDays = from time in await _alertTypeManager.GetAlertTypePeriodTimesByAlertType(alert.Id) select time.PeriodTimeId }); }