public bool UpdateHistory(History history) { bool hasUpdated = false; if (history != null) { HistoryEntity entity = new HistoryEntity { AppID = history.AppId, TitelID = history.AlbumId, LiedID = history.TrackId, Zeit = history.PlayedAt, Benutzer = history.UserName, Interpret = string.Empty, Titel = string.Empty, Lied = string.Empty }; using (TunesEntities tunesEntity = new TunesEntities(this.ConnectionString)) { tunesEntity.history.Add(entity); hasUpdated = tunesEntity.SaveChanges() > 0; } } return hasUpdated; }
public void UpdateHistory(History history) { this.m_dataService.UpdateHistory(history); }
private void OnMediaOpened() { try { this.PlayerService.CanExecuteNextTrack = this.CanExecuteNextTrack(); this.PlayerService.CanExecutePreviousTrack = this.CanExecutePreviousTrack(); string userName = "******"; TunesUser user = this.m_accountService.User; if (user != null && !string.IsNullOrEmpty(user.UserName)) { userName = user.UserName; } History history = new History { PlayMode = this.PlayerMode, AlbumId = this.CurrentTrack.Album.Id, TrackId = this.CurrentTrack.Id, UserName = userName, PlayedAt = DateTime.Now }; HistoryViewModel historyViewModel = new HistoryViewModel(this.m_dataService); historyViewModel.UpdateHistory(history); } catch { } }