示例#1
0
        public static Band CreateBand()
        {
            Band newBand = new Band()
            {
                Name = SetInformation.SetBandName()
            };

            return(newBand);
        }
示例#2
0
        public static void CreateAndSaveBand()
        {
            Band newBand = new Band()
            {
                Name = SetInformation.SetBandName()
            };

            using (var context = new MusicContext())
            {
                context.Bands.Add(newBand);
                context.SaveChanges();
            }
        }
示例#3
0
        public static Music CreateMusic(Band band)
        {
            Music newMusic = new Music()
            {
                Name = SetInformation.SetMusicName(),
                Band = band,
                SongDurationInSeconds = SetInformation.SetMusicDuration(),
                Lyrics = SetInformation.SetMusicLyrics(),
                Rating = SetInformation.SetMusicRating()
            };

            return(newMusic);
        }
示例#4
0
        public static void CreateAndSaveMusic(Guid bandId)
        {
            string name         = SetInformation.SetMusicName();
            int    songDuration = SetInformation.SetMusicDuration();
            string lyrics       = SetInformation.SetMusicLyrics();
            int    rating       = SetInformation.SetMusicRating();

            using (var context = new MusicContext())
            {
                Music newMusic = new Music()
                {
                    Name = name,
                    Band = context.Bands.Find(bandId),
                    SongDurationInSeconds = songDuration,
                    Lyrics = lyrics,
                    Rating = rating
                };
                context.Musics.Add(newMusic);
                context.SaveChanges();
            }
        }