Beispiel #1
0
        public async Task SaveCompleteReviewToSoup(MediaLink mediaLink, bool emailed, double viewedTime, string playListId, string contactId)
        {
            await DispatcherHelper.RunAsync(async() =>
            {
                var location = await _geolocationService.GetLocation();
                var store    = SmartStore.GetGlobalSmartStore();
                SetupSoupIfNotExistsNeeded(store, SoupName);

                var contentReview = new ContentReview
                {
                    ContentId            = mediaLink.ID,
                    ContentTitle         = mediaLink.Name,
                    PlaylistId           = string.IsNullOrWhiteSpace(playListId) ? string.Empty : playListId,
                    ContactId            = string.IsNullOrWhiteSpace(contactId) ? string.Empty : contactId,
                    GeolocationLatitude  = location.Latitude,
                    GeolocationLongitude = location.Longitude,
                    DocumentEmailed      = emailed,
                    Rating     = 0,
                    TimeViewed = viewedTime
                };

                SaveReview(store, contentReview);
                SyncUpContentReview();
            });
        }
        private async Task StopShowingMedia(MediaLink media)
        {
            if (media == null)
            {
                return;
            }

            var viewedSecond = (DateTime.Now - _startTime).TotalSeconds;

            // Clean up related content
            _relatedContent.Clear();
            Messenger.Default.Send(new RelatedContentMessage(_relatedContent));

            if (_presentationDataService.IsPresentationStarted())
            {
                var contentReview = new ContentReview
                {
                    ContentId       = media.ID,
                    ContentTitle    = media.Name,
                    PlaylistId      = _selectedPlayListId,
                    ContactId       = string.Empty,
                    DocumentEmailed = _contentEmailed,
                    Rating          = 0,
                    TimeViewed      = viewedSecond
                };
                _presentationDataService.AddContentReview(new ContentReviewInfo {
                    MediaLink = media, ContentReview = contentReview
                });
            }
            else
            {
                await _contentReviewDataService.SaveCompleteReviewToSoup(_media, _contentEmailed, viewedSecond, _selectedPlayListId, string.Empty);
            }
            Media = null;
        }
Beispiel #3
0
        private void SaveReview(SmartStore store, ContentReview contentReview)
        {
            var record = JObject.FromObject(contentReview,
                                            JsonSerializer.Create(CustomJsonSerializerSettings.Instance.Settings));

            record[SyncManager.Local] = true;

            var info = contentReview.GetType().GetTypeInfo().GetCustomAttributes()
                       .SingleOrDefault(t => t is JsonObjectAttribute) as JsonObjectAttribute;

            if (info != null)
            {
                record[Constants.SobjectType] = string.Format(info.Title,
                                                              SfdcConfig.CustomerPrefix);
            }
            record[SyncManager.LocallyCreated] = true;
            record[SyncManager.LocallyUpdated] = false;
            record[SyncManager.LocallyUpdated] = false;
            record[Constants.Id] = Guid.NewGuid();
            store.Upsert(SoupName, record, Constants.Id, false);
        }