예제 #1
0
        /// <summary>
        /// CHeck if a new show is a available and display the toast notification
        /// </summary>
        public override async Task CheckAndDisplayAsync()
        {
            // Resolve model
            IReadableLimitable <Show> model;

            using (ILifetimeScope scope = ViewModelLocator.Container.BeginLifetimeScope())
                model = scope.Resolve <IReadableLimitable <Show> >();

            // Get last show Id from model
            int idLastShow = await model.GetLastInsertedId();

            // Get last show saved Id
            int idLastShowSaved = 0;

            if (ApplicationData.Current.LocalSettings.Values[_storageKey] != null)
            {
                idLastShowSaved = (int)ApplicationData.Current.LocalSettings.Values[_storageKey];
            }

            // If Ids are differents, update the saved Id and show a toast notification
            if (idLastShow != idLastShowSaved)
            {
                Show show = await model.GetAsync(idLastShow);

                IToastImageAndText04 toastContent = ToastContentFactory.CreateToastImageAndText04();

                toastContent.Image.Src = show.ImageUrl;
                toastContent.Image.Alt = show.Name;

                toastContent.TextHeading.Text = ResourcesAccessor.GetString("Shows_New");
                toastContent.TextBody1.Text   = show.Name;
                toastContent.TextBody2.Text   = string.Format(ResourcesAccessor.GetString("Shows_DateFormat"), show.Start_DateTime, show.End_DateTime);

                ToastNotification toast = toastContent.CreateNotification();
                ToastNotificationManager.CreateToastNotifier().Show(toast);

                ApplicationData.Current.LocalSettings.Values[_storageKey] = idLastShow;
            }
        }
예제 #2
0
        /// <summary>
        /// CHeck if a new news is a available and display the toast notification
        /// </summary>
        public override async Task CheckAndDisplayAsync()
        {
            // Resolve model
            IReadableLimitable <News> model;

            using (ILifetimeScope scope = ViewModelLocator.Container.BeginLifetimeScope())
                model = scope.Resolve <IReadableLimitable <News> >();

            // Get last news Id from model
            int idLastNews = await model.GetLastInsertedId();

            // Get last news saved Id
            int idLastNewsSaved = 0;

            if (ApplicationData.Current.LocalSettings.Values[_storageKey] != null)
            {
                idLastNewsSaved = (int)ApplicationData.Current.LocalSettings.Values[_storageKey];
            }

            // If Ids are differents, update the saved Id and show a toast notification
            if (idLastNews != idLastNewsSaved)
            {
                News news = await model.GetAsync(idLastNews);

                IToastImageAndText04 toastContent = ToastContentFactory.CreateToastImageAndText04();

                toastContent.Image.Src = news.ImageUrl;
                toastContent.Image.Alt = news.Title;

                toastContent.TextHeading.Text = ResourcesAccessor.GetString("News_New");
                toastContent.TextBody1.Text   = news.Title;
                toastContent.TextBody2.Text   = news.ShortText;

                ToastNotification toast = toastContent.CreateNotification();
                ToastNotificationManager.CreateToastNotifier().Show(toast);

                ApplicationData.Current.LocalSettings.Values[_storageKey] = idLastNews;
            }
        }