protected void btnAddSong_Click(object sender, EventArgs e) { if (txtAddTitle.Text == "" || txtAddPrice.Text == "") { lblAddSongFeedback.Text = "Fill in all fields!"; return; } int artistID = int.Parse(ddlArtists.SelectedValue); string title = txtAddTitle.Text; int price = int.Parse(txtAddPrice.Text); _songDAL = new SongDAL(); int newID = _songDAL.AddSong(artistID, title, price); if (newID != 0) { selectedSong = newID.ToString(); lblAddSongFeedback.Text = "Addition success!"; } else { lblAddSongFeedback.Text = "Addition failed!"; } }
public void CountPlayback(SongViewModel song) { SongDAL songDAL = new SongDAL(); var songBE = songDAL.GetById(song.Id); var count = CacheManager.GetWithTimeout("songvoted" + songBE.Id + "-" + songBE.User.Id); if (count == null || Convert.ToInt32(count) < 5) { if (count == null) { CacheManager.SetWithTimeout("songvoted" + songBE.Id + "-" + songBE.User.Id, 0, TimeSpan.FromDays(7)); } else { CacheManager.Set("songvoted" + songBE.Id + "-" + songBE.User.Id, Convert.ToInt32(CacheManager.Get("songvoted" + songBE.Id + "-" + songBE.User.Id)) + 1); } if (songDAL.CountPlayback(songBE)) { DVVerifier dVVerifier = new DVVerifier(); UserDAL userdal = new UserDAL(); var userDVH = userdal.GetDVHEntity(songBE.User.Id); userDVH.DVH = dVVerifier.DVHCalculate(userDVH); userdal.SetDVH(userDVH); dVVerifier.DVCalculate("UserDAL"); } } }
public AdminController(IWebHostEnvironment hostingEnviroment) { unaddedEmployees = new List <Employee>(); buildingContainer = new BuildingContainer(); songDAL = new SongDAL(); songContainer = new SongContainer(songDAL); roomContainers = new List <RoomContainer>(); this.hostingEnviroment = hostingEnviroment; }
protected void FillOverview() { _songDAL = new SongDAL(); DataTable overviewTable = _songDAL.Overview(); DataView overviewView = overviewTable.DefaultView; overviewView.Sort = "Performer asc"; gvOverview.DataSource = overviewView; gvOverview.DataBind(); }
protected void SetUpdateCard() { int currentSongID = int.Parse(ddlSongs.SelectedValue); _songDAL = new SongDAL(); SongCollection song = _songDAL.GetSong(currentSongID); ddlUpdateArtist.SelectedValue = song.ArtistID.ToString(); txtUpdateTitle.Text = song.Title; txtUpdatePrice.Text = song.Price.ToString(); }
public SuccessViewModel CalculateSuccess(SongViewModel song) { try { SongBE entity; entity = Mapper.Map <SongViewModel, SongBE>(song); SongDAL songDAL = new SongDAL(); SuccessViewModel successViewModel = new SuccessViewModel(); var listSongs = songDAL.GetSongsToCalculate(entity.Category); (int sampleRate, double[] audio) = WavFile.ReadMono(FileUtils.GetRepoMusicPath(song.SongKey)); var spec = new Spectrogram.Spectrogram(sampleRate / 2, fftSize: (16384 / 8), stepSize: (2500 * 5), maxFreq: 2200); spec.Add(audio); var tempPath = Path.GetTempPath(); spec.SaveImage(tempPath + "/" + song.SongKey + ".jpg", intensity: 5, dB: true); var file = FileUtils.GetImageBytes(tempPath + "/" + song.SongKey + ".jpg"); successViewModel.ImageBase64 = "data:image/jpg;base64," + Convert.ToBase64String(file); var bmHash = this.GetHash(spec.GetBitmap()); List <Spectrogram.Spectrogram> spectrograms = new List <Spectrogram.Spectrogram>(); foreach (var son in listSongs) { (int sampleRateSong, double[] audioSong) = WavFile.ReadMono(FileUtils.GetRepoMusicPath(son.SongKey)); var specSong = new Spectrogram.Spectrogram(sampleRateSong / 2, fftSize: (16384 / 8), stepSize: (2500 * 5), maxFreq: 2200); specSong.Add(audioSong); spectrograms.Add(specSong); } int equalElements = 0; foreach (var sp in spectrograms) { equalElements += bmHash.Zip(this.GetHash(sp.GetBitmap()), (i, j) => i == j).Count(eq => eq); } var con = Convert.ToInt32(equalElements / spectrograms.Count); successViewModel.Percentage = Convert.ToInt32((con * 100) / bmHash.Count); return(successViewModel); } catch (Exception ex) { throw new Exception(Messages.Generic_Error); } }
protected void FillArtistDDL() { _songDAL = new SongDAL(); List <Artist> artists = _songDAL.GetAllArtists(); artists.Sort(); ddlArtists.DataSource = artists; ddlArtists.DataTextField = "Performer"; ddlArtists.DataValueField = "ArtistID"; ddlArtists.DataBind(); }
protected void FillSongDDL() { _songDAL = new SongDAL(); List <SongCollection> songs = _songDAL.GetAllSongs(); songs.Sort(); ddlSongs.DataSource = songs; ddlSongs.DataTextField = "Title"; ddlSongs.DataValueField = "SongID"; ddlSongs.DataBind(); }
protected void SetSearchCard() { int artistID = int.Parse(ddlArtists.SelectedValue); string zoekterm = txtSearch.Text; _songDAL = new SongDAL(); List <SongCollection> resultaat = _songDAL.SearchByPerformer(artistID, zoekterm); gvSearch.DataSource = resultaat; gvSearch.DataBind(); }
//HostingEnviroment word gebruikt voor het storen van fotos public CustomerController(IWebHostEnvironment hostingEnviroment) { songDAL = new SongDAL(); userDAL = new UserDAL(); playlistDAL = new PlaylistDAL(); songContainer = new SongContainer(songDAL); userContainer = new UserContainer(userDAL); playlistContainer = new PlaylistContainer(playlistDAL); songViewModel = new SongViewModel(); song = new Song(); this.hostingEnviroment = hostingEnviroment; }
public IList <SongViewModel> GetSongsVoted(UserViewModel user) { SongDAL songDAL = new SongDAL(); var userbe = Mapper.Map <UserViewModel, UserBE>(user); var svm = Mapper.Map <SongBE, SongViewModel>(songDAL.GetSongsVoted(userbe)); foreach (var song in svm) { var file = FileUtils.GetImageBytes(FileUtils.GetRepoImagePath(song.Album.ImgKey)); song.Album.ImageBase64 = "data:image/jpg;base64," + Convert.ToBase64String(file); } return(svm); }
public IList <SongViewModel> GetReport() { try { SongDAL songDAL = new SongDAL(); var svm = Mapper.Map <SongBE, SongViewModel>(songDAL.GetSongsReport()); return(svm); } catch (Exception ex) { throw new Exception(Messages.Generic_Error); } }
protected void btnDelete_Click(object sender, EventArgs e) { int songID = int.Parse(ddlSongs.SelectedValue); _songDAL = new SongDAL(); if (_songDAL.DeleteSong(songID)) { lblDeleteFeedback.Text = "Delete success!"; } else { lblDeleteFeedback.Text = "Delete failed!"; } }
/// <summary> /// Save the song /// </summary> public static void SaveSong(Song song) { if (!song.Validate()) { throw new ValidationException(); } if (song.SongID == 0) { SongDAL.InsertSong(song); } else { SongDAL.UpdateSong(song); } }
public UserViewModel GetUserSongs(UserViewModel user) { try { SongDAL songDAL = new SongDAL(); IList <SongBE> entities; UserBE userBE = Mapper.Map <UserViewModel, UserBE>(user); entities = songDAL.GetUserSongs(userBE); userBE.Songs = entities.ToList(); return(Mapper.Map <UserBE, UserViewModel>(userBE)); } catch (Exception ex) { throw new Exception(Messages.Generic_Error); } }
protected void btnSavePreference_Click(object sender, EventArgs e) { string userID = Request.QueryString["user"]; int performer = int.Parse(ddlArtists.SelectedValue); int title = int.Parse(ddlSongs.SelectedValue); _songDAL = new SongDAL(); if (_songDAL.SavePreference(userID, performer, title)) { lblSaveFeedback.Text = "Preference saved!"; } else { lblSaveFeedback.Text = "Save failed!"; } }
protected void ApplyPreferences() { _songDAL = new SongDAL(); Preference preference = _songDAL.GetPreference(Request.QueryString["user"]); if (preference.Performer != -1 && ddlArtists.Items.FindByValue(preference.Performer.ToString()) != null) { ddlArtists.SelectedValue = preference.Performer.ToString(); } if (preference.Title != -1 && ddlSongs.Items.FindByValue(preference.Title.ToString()) != null) { ddlSongs.SelectedValue = preference.Title.ToString(); } else { lblSaveFeedback.Text = "Your saved song doesn't exist."; } }
protected void btnUpdateSong_Click(object sender, EventArgs e) { if (txtUpdateTitle.Text == "" || txtUpdatePrice.Text == "") { lblUpdateSongFeedback.Text = "No empty fields!"; return; } int songID = int.Parse(ddlSongs.SelectedValue); string title = txtUpdateTitle.Text; int artistID = int.Parse(ddlUpdateArtist.SelectedValue); int price = int.Parse(txtUpdatePrice.Text); _songDAL = new SongDAL(); if (_songDAL.UpdateSong(songID, title, artistID, price)) { lblUpdateSongFeedback.Text = "Update success!"; } else { lblUpdateSongFeedback.Text = "Update failed!"; } }
public UserEventGenerator() { this.songDAL = new SongDAL(); this.usersList = new UserDAL().getUsers(); this.songIds = this.songDAL.getSongIds().ToList(); }
private IList <SongBE> GetCategorySongs(CategoryBE category, UserBE user) { SongDAL songDAL = new SongDAL(); return(songDAL.GetCategorySongs(category, user)); }
private IList <SongBE> GetRandomSongs(UserBE user) { SongDAL songDAL = new SongDAL(); return(songDAL.GetRandomSongs(user)); }
/// <summary> /// Get an albums songs /// </summary> public static IEnumerable <SongArtist> GetSongsByAlbumId(int albumID) { return(SongDAL.GetSongsByAlbumId(albumID)); }
/// <summary> /// Get a song /// </summary> public static SongArtist GetSongById(int songID) { return(SongDAL.GetSongById(songID)); }
/// <summary> /// Delete a song /// </summary> public static void DeleteSong(int songID) { SongDAL.DeleteSong(songID); }
private IList <SongBE> GetSimilarVotesSongs(UserBE user) { SongDAL songDAL = new SongDAL(); return(songDAL.GetSimilarVotesSongs(user)); }