/// <summary> /// Add Alert /// </summary> public async Task UpdateAlertsByRequest(Request request, string linkToRequest) { var managerRequest = await _userManager.GetManagerAsync(request.ManagerId ?? 0); if (managerRequest == null) { return; } var allAlertTypes = await _alertTypeManager.GetAllAlertTypes(); var link = $"<a href='{linkToRequest}' target='_blank'>Link</a>"; foreach (var detail in request.Details) { foreach (var alertType in allAlertTypes) { async Task UpdateAlert(DateTime?date) { if (!date.HasValue) { return; } await UpdatedAlert( alertType.Id, alertType.Message, alertType.Name, alertType.IsSendingEmail, request.Id, managerRequest.Email, date.Value, link); } switch (alertType.Name) { case AlertType.SupplierPaymentDue: await UpdateAlert(detail.PaymentDueDate); break; case AlertType.ConfirmedDeliveryDate: await UpdateAlert(detail.ConfirmedDeliveryDate); break; case AlertType.ServiceDue: await UpdateAlert(detail.ServiceDueDate); break; case AlertType.DeInstallDue: await UpdateAlert(detail.DeInstallDueDate); break; } } } }
public async Task <JsonResult> AlertList() { var alerts = await _alertTypeManager.GetAllAlertTypes(); var notifyTimes = await _alertTypeManager.GetPeriodTimes(); var alertList = new List <AlertTypeViewModel>(); foreach (var alert in alerts) { alertList.Add(await BuildAlertTypeViewModel(alert)); } return(Json(new { Alerts = alertList, NotifyTimes = notifyTimes })); }