コード例 #1
0
ファイル: SetlistHelper.cs プロジェクト: jyuma/SetGenerator
        public Setlist GenerateSets(IEnumerable<Song> masterSongList, SetlistDetail setlistDetail, int bandId, User currentUser)
        {
            if (masterSongList == null) return null;

            var songs = masterSongList.ToArray();
            var numSets = setlistDetail.NumSets;
            var numSetSongs = setlistDetail.NumSongs;

            var setlist = new Setlist
            {
                Band = _bandRepository.Get(bandId),
                Name = setlistDetail.Name,
                DateCreate = DateTime.Now,
                DateUpdate = DateTime.Now,
                UserCreate = currentUser,
                UserUpdate = currentUser,
                SetSongs = new Collection<SetSong>()
            };

            IEnumerable<SetSong> setSongs;

            var numChanges = GetNumberInstrumentChanges(songs);

            switch (numChanges)
            {
                case 0:
                {
                    var keyGenereTempo = new KeyGenreTempo();
                    setSongs = keyGenereTempo.Generate(numSets, numSetSongs, songs);
                    break;
                }
                    
                default:
                {
                    var instrumentSinger = new InstrumentSinger();
                    setSongs = instrumentSinger.Generate(numSets, numSetSongs, songs);
                    break;
                }
            }

            if (setSongs == null) return setlist;

            foreach (var setSong in setSongs)
            {
                setSong.Setlist = setlist;
                setlist.SetSongs.Add(setSong);
            }

            return setlist;
        }
コード例 #2
0
 private void UpdateSetlist(SetlistDetail setlistDetail)
 {
     var setlist = _setlistRepository.Get(setlistDetail.Id);
     if (setlist != null)
     {
         setlist.Name = setlistDetail.Name;
         setlist.UserUpdate = _currentUser;
         setlist.DateUpdate = DateTime.Now;
     };
     _setlistRepository.Update(setlist);
 }