/// <summary>
        ///     When a notification is recieved update the repository and show
        ///     the recieved notification to the user.
        /// </summary>
        /// <param name="notification"></param>
        public void NotificationReceived(Notification notification)
        {
            // Copy the notification values to the view model
            var viewModel = new NotificationRecievedViewModel
            {
                Id      = notification.Id,
                Title   = notification.Title,
                Message = notification.Message
            };

            // Only copy the extra info if it exists.
            if (notification.ExtraInfo.ContainsKey("ExtraInfoOne"))
            {
                viewModel.ExtraInfoOne = notification.ExtraInfo["ExtraInfoOne"];
            }

            if (notification.ExtraInfo.ContainsKey("ExtraInfoTwo"))
            {
                viewModel.ExtraInfoTwo = notification.ExtraInfo["ExtraInfoTwo"];
            }


            // Save the recieved view model.
            ScheduledNotificationRepository.NotificationRecieved(notification.Id, viewModel.Title, viewModel.Message, viewModel.ExtraInfoOne, viewModel.ExtraInfoTwo);


            // Show the notifcation page.
            var notificationPage = new NotificationRecievedPage(viewModel);

            Application.Current.MainPage.Navigation.PushAsync(notificationPage);
        }
Exemple #2
0
        /// <summary>
        ///     Create a new notification page and bind it to the view model.
        /// </summary>
        /// <param name="viewModel">The notification values.</param>
        public NotificationRecievedPage([NotNull] NotificationRecievedViewModel viewModel)
        {
            InitializeComponent();

            BindingContext = viewModel;
        }