public IActionResult EditSong(IFormCollection formCollection, string songName, string fileName, int id) { MusicTrack song = musicRepo.GetMusicTrackById(id); var collection = formCollection; GenreTag genreTag = musicRepo.GetGenreTagFromDataBase(collection["genre"]); song.Name = songName; song.Genre = genreTag; song.FileName = fileName; musicRepo.DeleteMusicTrackMoodTags(song); musicRepo.DeleteMusicTrackInstrumentTags(song); song.Moods = new List <MoodTag>(); song.Instruments = new List <InstrumentTag>(); song.MusicTrackMoodTags = new List <MusicTrackMoodTag>(); song.MusicTrackInstrumentTags = new List <MusicTrackInstrumentTag>(); for (int i = 0; i <= musicRepo.MoodList.Count; i++) { string mood = "mood" + i.ToString(); string value = collection[mood]; if (value != null) { MoodTag moodTag = musicRepo.GetMoodTagFromDatabase(value); song.Moods.Add(moodTag); var m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = moodTag; song.MusicTrackMoodTags.Add(m); } } for (int i = 0; i <= musicRepo.InstrumentList.Count; i++) { string instrument = "instrument" + i.ToString(); string value = collection[instrument]; if (value != null) { InstrumentTag instrumentTag = musicRepo.GetInstrumentTagFromDatabase(value); song.Instruments.Add(instrumentTag); var m = new MusicTrackInstrumentTag(); m.MusicTrack = song; m.InstrumentTag = instrumentTag; song.MusicTrackInstrumentTags.Add(m); } } musicRepo.MusicTracks.Add(song); musicRepo.UpdateSongInDatabase(song); return(RedirectToRoute("AdminManageSongs")); }
public RedirectToActionResult AddSong(IFormCollection formCollection, string songName, string fileName) { var collection = formCollection; GenreTag genreTag = musicRepo.GetGenreTagFromDataBase(collection["genre"]); MusicTrack song = new MusicTrack(); song.Name = songName; song.Genre = genreTag; song.FileName = fileName; List <MoodTag> moodTags = new List <MoodTag>(); for (int i = 0; i <= musicRepo.MoodList.Count; i++) { string mood = "mood" + i.ToString(); string value = collection[mood]; if (value != null) { MoodTag moodTag = musicRepo.GetMoodTagFromDatabase(value); song.Moods.Add(moodTag); var m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = moodTag; song.MusicTrackMoodTags.Add(m); } string instrument = "instrument" + i.ToString(); value = collection[instrument]; if (value != null) { InstrumentTag instrumentTag = musicRepo.GetInstrumentTagFromDatabase(value); song.Instruments.Add(instrumentTag); var m = new MusicTrackInstrumentTag(); m.MusicTrack = song; m.InstrumentTag = instrumentTag; song.MusicTrackInstrumentTags.Add(m); } } musicRepo.MusicTracks.Add(song); musicRepo.SaveSongToDatabase(song); return(RedirectToAction("Music")); }
public static void Seed(IApplicationBuilder app) { ApplicationDbContext context = app.ApplicationServices.GetRequiredService <ApplicationDbContext>(); context.Database.EnsureCreated(); if (!context.MusicTracks.Any()) { // Adding Genre Tags GenreTag acoustic = new GenreTag(); acoustic.Tag = "Acoustic"; context.GenreTags.Add(acoustic); GenreTag ambient = new GenreTag(); ambient.Tag = "Ambient"; context.GenreTags.Add(ambient); GenreTag cinematic = new GenreTag(); cinematic.Tag = "Cinematic"; context.GenreTags.Add(cinematic); GenreTag corporate = new GenreTag(); corporate.Tag = "Corporate"; context.GenreTags.Add(corporate); GenreTag electronica = new GenreTag(); electronica.Tag = "Electronica"; context.GenreTags.Add(electronica); GenreTag holiday = new GenreTag(); holiday.Tag = "Holiday"; context.GenreTags.Add(holiday); GenreTag pop = new GenreTag(); pop.Tag = "Pop"; context.GenreTags.Add(pop); GenreTag rock = new GenreTag(); rock.Tag = "Rock"; context.GenreTags.Add(rock); // Adding Mood Tags MoodTag beautiful = new MoodTag(); beautiful.Tag = "beautiful"; context.MoodTags.Add(beautiful); MoodTag dark = new MoodTag(); dark.Tag = "dark"; context.MoodTags.Add(dark); MoodTag dramatic = new MoodTag(); dramatic.Tag = "dramatic"; context.MoodTags.Add(dramatic); MoodTag emotional = new MoodTag(); emotional.Tag = "emotional"; context.MoodTags.Add(emotional); MoodTag energetic = new MoodTag(); energetic.Tag = "energetic"; context.MoodTags.Add(energetic); MoodTag epic = new MoodTag(); epic.Tag = "epic"; context.MoodTags.Add(epic); MoodTag fun = new MoodTag(); fun.Tag = "fun"; context.MoodTags.Add(fun); MoodTag gentle = new MoodTag(); gentle.Tag = "gentle"; context.MoodTags.Add(gentle); MoodTag happy = new MoodTag(); happy.Tag = "happy"; context.MoodTags.Add(happy); MoodTag hopeful = new MoodTag(); hopeful.Tag = "hopeful"; context.MoodTags.Add(hopeful); MoodTag inspirational = new MoodTag(); inspirational.Tag = "inspirational"; context.MoodTags.Add(inspirational); MoodTag joyful = new MoodTag(); joyful.Tag = "joyful"; context.MoodTags.Add(joyful); MoodTag light = new MoodTag(); light.Tag = "light"; context.MoodTags.Add(light); MoodTag motivational = new MoodTag(); motivational.Tag = "motivational"; context.MoodTags.Add(motivational); MoodTag optimistic = new MoodTag(); optimistic.Tag = "optimistic"; context.MoodTags.Add(optimistic); MoodTag peaceful = new MoodTag(); peaceful.Tag = "peaceful"; context.MoodTags.Add(peaceful); MoodTag powerful = new MoodTag(); powerful.Tag = "powerful"; context.MoodTags.Add(powerful); MoodTag relaxing = new MoodTag(); relaxing.Tag = "relaxing"; context.MoodTags.Add(relaxing); MoodTag romantic = new MoodTag(); romantic.Tag = "romantic"; context.MoodTags.Add(romantic); MoodTag sentimental = new MoodTag(); sentimental.Tag = "sentimental"; context.MoodTags.Add(sentimental); MoodTag suspenseful = new MoodTag(); suspenseful.Tag = "suspenseful"; context.MoodTags.Add(suspenseful); MoodTag upbeat = new MoodTag(); upbeat.Tag = "upbeat"; context.MoodTags.Add(upbeat); MoodTag uplifting = new MoodTag(); uplifting.Tag = "uplifting"; context.MoodTags.Add(uplifting); // Add Instrument Tags InstrumentTag acousticGuitar = new InstrumentTag(); acousticGuitar.Tag = "acoustic guitar"; context.InstrumentTags.Add(acousticGuitar); InstrumentTag bass = new InstrumentTag(); bass.Tag = "bass"; context.InstrumentTags.Add(bass); InstrumentTag cello = new InstrumentTag(); cello.Tag = "cello"; context.InstrumentTags.Add(cello); InstrumentTag percussion = new InstrumentTag(); percussion.Tag = "percussion"; context.InstrumentTags.Add(percussion); InstrumentTag piano = new InstrumentTag(); piano.Tag = "piano"; context.InstrumentTags.Add(piano); InstrumentTag strings = new InstrumentTag(); strings.Tag = "strings"; context.InstrumentTags.Add(strings); InstrumentTag synth = new InstrumentTag(); synth.Tag = "synth"; context.InstrumentTags.Add(synth); InstrumentTag violin = new InstrumentTag(); violin.Tag = "violin"; context.InstrumentTags.Add(violin); // Add Other Tags OtherTag beach = new OtherTag(); beach.Tag = "beach"; context.OtherTags.Add(beach); OtherTag beauty = new OtherTag(); beauty.Tag = "beauty"; context.OtherTags.Add(beauty); OtherTag brave = new OtherTag(); brave.Tag = "brave"; context.OtherTags.Add(brave); // Add Songs MusicTrack song = new MusicTrack(); song.Name = "Beautiful Cinematic Piano"; song.Genre = cinematic; song.FileName = "Beautiful-Cinematic-Piano.mp3"; List <MoodTag> moods = new List <MoodTag> { beautiful, emotional, gentle, hopeful, inspirational, optimistic, peaceful, relaxing, romantic, sentimental, uplifting }; var m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = beautiful; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = emotional; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = gentle; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = hopeful; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = inspirational; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = optimistic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = peaceful; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = relaxing; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = romantic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = uplifting; song.MusicTrackMoodTags.Add(m); List <InstrumentTag> instruments = new List <InstrumentTag> { cello, piano, violin }; var i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = cello; song.MusicTrackInstrumentTags.Add(i); i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = piano; song.MusicTrackInstrumentTags.Add(i); i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = violin; song.MusicTrackInstrumentTags.Add(i); context.MusicTracks.Add(song); song = new MusicTrack(); song.Name = "Epic Cinematic Trailer"; song.Genre = cinematic; song.FileName = "Epic-Cinematic-Trailer.mp3"; moods = new List <MoodTag> { dark, dramatic, energetic, epic, inspirational, motivational, powerful, suspenseful, upbeat }; m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = dark; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = dramatic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = energetic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = epic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = inspirational; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = motivational; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = powerful; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = suspenseful; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = upbeat; song.MusicTrackMoodTags.Add(m); instruments = new List <InstrumentTag> { cello, percussion, violin, strings }; i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = cello; song.MusicTrackInstrumentTags.Add(i); i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = percussion; song.MusicTrackInstrumentTags.Add(i); i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = strings; song.MusicTrackInstrumentTags.Add(i); i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = violin; song.MusicTrackInstrumentTags.Add(i); context.MusicTracks.Add(song); song = new MusicTrack(); song.Name = "Epic Upbeat Cinematic Percussion"; song.Genre = cinematic; song.FileName = "Epic-Upbeat-Cinematic-Percussion.mp3"; moods = new List <MoodTag> { dark, dramatic, energetic, epic, inspirational, motivational, powerful, suspenseful, upbeat }; m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = dark; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = dramatic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = energetic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = epic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = inspirational; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = motivational; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = powerful; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = suspenseful; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = upbeat; song.MusicTrackMoodTags.Add(m); instruments = new List <InstrumentTag> { percussion }; i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = percussion; song.MusicTrackInstrumentTags.Add(i); var tags = new List <OtherTag> { brave }; var t = new MusicTrackOtherTag(); t.MusicTrack = song; t.OtherTag = brave; song.MusicTrackOtherTags.Add(t); context.MusicTracks.Add(song); song = new MusicTrack(); song.Name = "Happy Acoustic Summer Whistle"; song.Genre = acoustic; song.FileName = "Happy-Acoustic-Summer-Whistle.mp3"; moods = new List <MoodTag> { energetic, fun, happy, hopeful, inspirational, joyful, light, optimistic, upbeat, uplifting }; m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = energetic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = fun; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = happy; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = hopeful; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = inspirational; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = joyful; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = light; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = optimistic; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = upbeat; song.MusicTrackMoodTags.Add(m); m = new MusicTrackMoodTag(); m.MusicTrack = song; m.MoodTag = uplifting; song.MusicTrackMoodTags.Add(m); instruments = new List <InstrumentTag> { acousticGuitar, bass, piano, percussion, synth }; i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = acousticGuitar; song.MusicTrackInstrumentTags.Add(i); i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = bass; song.MusicTrackInstrumentTags.Add(i); i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = piano; song.MusicTrackInstrumentTags.Add(i); i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = percussion; song.MusicTrackInstrumentTags.Add(i); i = new MusicTrackInstrumentTag(); i.MusicTrack = song; i.InstrumentTag = synth; song.MusicTrackInstrumentTags.Add(i); tags = new List <OtherTag> { beach }; t = new MusicTrackOtherTag(); t.MusicTrack = song; t.OtherTag = beach; song.MusicTrackOtherTags.Add(t); context.MusicTracks.Add(song); ////////////////////////////////////////////////////////////////////////////////////////////////////////// SAVE CHANGES /////////////////////////////// context.SaveChanges(); } }
public void AddSeedData() { //List<string> allMoods = new List<string>{ "beautiful", "dark", "dramatic", "emotional", "energetic", "epic", "fun", "gentle", "happy", "hopeful", "inspirational", "joyful", "light", "motivational", "optimistic", "peaceful", "powerful", "relaxing", "romantic", "sad", "sentimental", "suspenseful", "upbeat", "uplifting" }; //moodList.AddRange(allMoods); //List<string> allInstruments = new List<string> { "acoustic guitar", "bass", "cello", "percussion", "piano", "strings", "synth", "violin" }; //instrumentList.AddRange(allInstruments); //List<string> allGenres = new List<string> { "Acoustic", "Ambient", "Cinematic", "Corporate", "Electronica", "Holiday", "Other", "Pop", "Rock" }; //genreList.AddRange(allGenres); GenreTag cinematic = new GenreTag(); cinematic.Tag = "Cinematic"; GenreTag acoustic = new GenreTag(); acoustic.Tag = "Acoustic"; MoodTag beautiful = new MoodTag(); beautiful.Tag = "beautiful"; MoodTag dark = new MoodTag(); dark.Tag = "dark"; MoodTag dramatic = new MoodTag(); dramatic.Tag = "dramatic"; MoodTag emotional = new MoodTag(); emotional.Tag = "emotional"; MoodTag energetic = new MoodTag(); energetic.Tag = "energetic"; MoodTag epic = new MoodTag(); epic.Tag = "epic"; MoodTag fun = new MoodTag(); fun.Tag = "fun"; MoodTag gentle = new MoodTag(); gentle.Tag = "gentle"; MoodTag happy = new MoodTag(); happy.Tag = "happy"; MoodTag hopeful = new MoodTag(); hopeful.Tag = "hopeful"; MoodTag inspirational = new MoodTag(); inspirational.Tag = "inspirational"; MoodTag joyful = new MoodTag(); joyful.Tag = "joyful"; MoodTag light = new MoodTag(); light.Tag = "light"; MoodTag motivational = new MoodTag(); motivational.Tag = "motivational"; MoodTag optimistic = new MoodTag(); optimistic.Tag = "optimistic"; MoodTag peaceful = new MoodTag(); peaceful.Tag = "peaceful"; MoodTag powerful = new MoodTag(); powerful.Tag = "powerful"; MoodTag relaxing = new MoodTag(); relaxing.Tag = "relaxing"; MoodTag romantic = new MoodTag(); romantic.Tag = "romantic"; MoodTag sentimental = new MoodTag(); sentimental.Tag = "sentimental"; MoodTag suspenseful = new MoodTag(); suspenseful.Tag = "suspenseful"; MoodTag upbeat = new MoodTag(); upbeat.Tag = "upbeat"; MoodTag uplifting = new MoodTag(); uplifting.Tag = "uplifting"; InstrumentTag acousticGuitar = new InstrumentTag(); acousticGuitar.Tag = "acoustic guitar"; InstrumentTag bass = new InstrumentTag(); bass.Tag = "bass"; InstrumentTag cello = new InstrumentTag(); cello.Tag = "cello"; InstrumentTag percussion = new InstrumentTag(); percussion.Tag = "percussion"; InstrumentTag piano = new InstrumentTag(); piano.Tag = "piano"; InstrumentTag strings = new InstrumentTag(); strings.Tag = "strings"; InstrumentTag synth = new InstrumentTag(); synth.Tag = "synth"; InstrumentTag violin = new InstrumentTag(); violin.Tag = "violin"; OtherTag beach = new OtherTag(); beach.Tag = "beach"; OtherTag beauty = new OtherTag(); beauty.Tag = "beauty"; OtherTag brave = new OtherTag(); brave.Tag = "brave"; List <MoodTag> moods = new List <MoodTag> { beautiful, emotional, gentle, hopeful, inspirational, optimistic, peaceful, relaxing, romantic, sentimental, uplifting }; List <InstrumentTag> instruments = new List <InstrumentTag> { cello, piano, violin }; List <OtherTag> tags = new List <OtherTag> { beauty }; MusicTrack song = new MusicTrack(); song.Name = "Beautiful Cinematic Piano"; song.Genre = cinematic; song.FileName = "Beautiful-Cinematic-Piano.mp3"; song.Moods = moods; song.AddInstruments(instruments); song.AddTags(tags); AddMusicTrack(song); moods = new List <MoodTag> { dark, dramatic, energetic, epic, inspirational, motivational, powerful, suspenseful, upbeat }; instruments = new List <InstrumentTag> { cello, percussion, violin, strings }; tags = new List <OtherTag> { beauty, brave }; song = new MusicTrack(); song.Name = "Epic Cinematic Trailer"; song.Genre = cinematic; song.FileName = "Epic-Cinematic-Trailer.mp3"; song.Moods = moods; song.AddInstruments(instruments); song.AddTags(tags); AddMusicTrack(song); instruments = new List <InstrumentTag> { percussion }; tags = new List <OtherTag> { brave }; song = new MusicTrack(); song.Name = "Epic Upbeat Cinematic Percussion"; song.Genre = cinematic; song.FileName = "Epic-Upbeat-Cinematic-Percussion.mp3"; song.Moods = moods; song.AddInstruments(instruments); song.AddTags(tags); AddMusicTrack(song); moods = new List <MoodTag> { energetic, fun, happy, hopeful, inspirational, joyful, light, optimistic, upbeat, uplifting }; instruments = new List <InstrumentTag> { acousticGuitar, bass, piano, percussion, synth }; tags = new List <OtherTag> { beach }; song = new MusicTrack(); song.Name = "Happy Acoustic Summer Whistle"; song.Genre = acoustic; song.FileName = "Happy-Acoustic-Summer-Whistle.mp3"; song.Moods = moods; song.AddInstruments(instruments); song.AddTags(tags); AddMusicTrack(song); }