public bool UpdateServiceItem(DataModel_Channel data) { // 1. find the item in DB to update var item = from c in _dbEngine.CmtvDBContext.Service_items where c.ID == data.ID select c; Table_Service t = item.FirstOrDefault(); // 2. assign values t.ServiceName = data.ChannelName; t.Description = data.Description; t.ForFree = data.Free; t.Genre = data.Genre; // 3. submit changes try { _dbEngine.CmtvDBContext.SubmitChanges(); } catch { return(false); } return(true); }
public void ReadAllChannelsToDC() { //if (!isAddedToCollection) // refresh the view everytime this.DC_AllChannels.Clear(); IEnumerator <Table_Service> enumerator = _dbEngine.CmtvDBContext.Service_items.GetEnumerator(); while (enumerator.MoveNext()) { DataModel_Channel d = new DataModel_Channel { ChannelName = enumerator.Current.ServiceName, Description = enumerator.Current.Description, ID = enumerator.Current.ID, Genre = enumerator.Current.Genre, Free = enumerator.Current.ForFree, IsFavorite = enumerator.Current.IsFavorite }; // get the content from service ID var contents = QueryContentFromServiceID(enumerator.Current.ID); // only pickup the first item if (contents.Count > 0) { d.CurrentContentName = contents.FirstOrDefault().ProgramName; d.CurrentContentStartTime = contents.FirstOrDefault().StartTime; d.CurrentContentEndTime = contents.FirstOrDefault().EndTime; } this.DC_AllChannels.Add(d); } }
public void PrepareToPlayNextChannel() { IEnumerator <DataModel_Channel> enumerator = _uiDataModel.DC_AllChannels.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Current.ID == m_curPlayingChannel.ID) { if (enumerator.MoveNext()) { m_curPlayingChannel = enumerator.Current; } else { // reach the end, back to the first enumerator.Reset(); while (enumerator.MoveNext()) { m_curPlayingChannel = enumerator.Current; break; } } break; } } _provider.CancelProviding(); }
public void PrepareToPlayChannel(DataModel_Channel dc) { m_curPlayingChannel = dc; _provider.CancelProviding(); // _provider.StartToProvide(); //_provider. }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { // when this page is loaded. base.OnNavigatedTo(e); string id = ""; if (NavigationContext.QueryString.TryGetValue("SelectedItem", out id)) { // Initializing data collections var dataset = App.EngineInstance.GetUIDataModel.QueryServiceFromID(id); currentService = dataset.FirstOrDefault(); serviceExts = App.EngineInstance.GetUIDataModel.QueryServiceExtFromID(currentService.ID); } UpdateView(); }
public bool UpdateServiceItem(DataModel_Channel data) { // 1. find the item in DB to update var item = from c in _dbEngine.CmtvDBContext.Service_items where c.ID == data.ID select c; Table_Service t = item.FirstOrDefault(); // 2. assign values t.ServiceName = data.ChannelName; t.Description = data.Description; t.ForFree = data.Free; t.Genre = data.Genre; // 3. submit changes try { _dbEngine.CmtvDBContext.SubmitChanges(); } catch { return false; } return true; }
public void ReadAllChannelsToDC() { //if (!isAddedToCollection) // refresh the view everytime this.DC_AllChannels.Clear(); IEnumerator<Table_Service> enumerator = _dbEngine.CmtvDBContext.Service_items.GetEnumerator(); while (enumerator.MoveNext()) { DataModel_Channel d = new DataModel_Channel { ChannelName = enumerator.Current.ServiceName, Description = enumerator.Current.Description, ID = enumerator.Current.ID, Genre = enumerator.Current.Genre, Free = enumerator.Current.ForFree, IsFavorite = enumerator.Current.IsFavorite }; // get the content from service ID var contents = QueryContentFromServiceID(enumerator.Current.ID); // only pickup the first item if (contents.Count > 0) { d.CurrentContentName = contents.FirstOrDefault().ProgramName; d.CurrentContentStartTime = contents.FirstOrDefault().StartTime; d.CurrentContentEndTime = contents.FirstOrDefault().EndTime; } this.DC_AllChannels.Add(d); } }
public void PrepareToPlayNextChannel() { IEnumerator<DataModel_Channel> enumerator = _uiDataModel.DC_AllChannels.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Current.ID == m_curPlayingChannel.ID) { if (enumerator.MoveNext()) m_curPlayingChannel = enumerator.Current; else { // reach the end, back to the first enumerator.Reset(); while (enumerator.MoveNext()) { m_curPlayingChannel = enumerator.Current; break; } } break; } } _provider.CancelProviding(); }