public bool DeletePurchasedSong(PurchasedSong purchasedSong) { try { PurchasedSongTable.DeleteOnSubmit(purchasedSong); PurchasedSongTable.Context.SubmitChanges(); return true; } catch (Exception) { return false; } }
public bool SavePurchasedSong(PurchasedSong purchasedSong) { try { if (purchasedSong.PurchasedSongId == 0) { PurchasedSongTable.InsertOnSubmit(purchasedSong); } else { PurchasedSongTable.Context.Refresh(RefreshMode.KeepCurrentValues, purchasedSong); } PurchasedSongTable.Context.SubmitChanges(); return true; } catch (Exception) { return false; } }
public bool RecordSongPlayByUser(int songId, int playlistId, int userId) { var playlistSongId = GetPlaylistSongCollection(playlistId).Where(s => s.SongId == songId).Select(p => p.PlaylistSongId).FirstOrDefault(); var purchasedSong = new PurchasedSong() { UserId = userId, Cost = 0, DatePurchased = DateTime.Now, PlaylistSongId = playlistSongId }; try { var success = SqlPurchasedSongRepository.SavePurchasedSong(purchasedSong); return success; } catch { return false; } }