public async Task <IActionResult> Edit([Bind] ScheduledNotificationViewModel scheduledNotificationViewModel) { ScheduledNotificationDTO scheduledNotification = scheduledNotificationViewModel.ScheduledNotification; string url = $"{NotificationsApiUrl}ScheduledNotifications/Update"; var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Put(accessToken, url, scheduledNotification); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Scheduled notification has been successfully updated", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to update scheduled notification", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } scheduledNotificationViewModel.EscalationRules = await GetEscalationRules(); scheduledNotificationViewModel.NotificationTemplates = await GetNotificationTemplates(); scheduledNotificationViewModel.NotificationChannels = await GetNotificationChannels(); return(View(scheduledNotificationViewModel)); }
/// <summary> /// Creates a new page with the scheduled notification loaded. /// </summary> /// <param name="scheduledNotificationId"></param> public ScheduledNotificationPage(string scheduledNotificationId) : this() { var scheduledNotification = ScheduledNotificationRepository.FindNotification(scheduledNotificationId); BindingContext = new ScheduledNotificationViewModel { Id = scheduledNotification.Id, NumberOfTimesRecieved = scheduledNotification.NumberTimesRecieved, CreatedOn = scheduledNotification.CreatedOn.ToString("G"), ScheduledFor = scheduledNotification.ScheduledFor.ToString("G"), RecievedOn = scheduledNotification.LastRecievedOn?.ToString("G") ?? "", ScheduledTitle = scheduledNotification.ScheduledDetails?.Title ?? "", RecievedTitle = scheduledNotification.RecievedDetails?.Title ?? "", ScheduledMessage = scheduledNotification.ScheduledDetails?.Message ?? "", RecivedMessage = scheduledNotification.RecievedDetails?.Message ?? "", ScheduledExtraInfoOne = scheduledNotification.ScheduledDetails?.ExtraInfoOne ?? "", RecivedExtraInfoOne = scheduledNotification.RecievedDetails?.ExtraInfoOne ?? "", ScheduledExtraInfoTwo = scheduledNotification.ScheduledDetails?.ExtraInfoTwo ?? "", RecivedExtraInfoTwo = scheduledNotification.RecievedDetails?.ExtraInfoTwo ?? "", CanceledOn = scheduledNotification.CanceledOn?.ToString("G") ?? "" }; }