예제 #1
0
        public GenresController (   IGenreRepository genreRepository,
                                    ISongRepository songRepository,
                                    IValidationRules validationRules,
                                    IAccount account)
        {
            _genreRepository = genreRepository;
            _songRepository = songRepository;
            _validationRules = validationRules;

            var currentUserName = GetCurrentSessionUser();
            if (currentUserName.Length > 0)
                _currentUser = account.GetUserByUserName(currentUserName);
            _common = new CommonSong(account, currentUserName);
        }
예제 #2
0
        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;
        }
예제 #3
0
        public UsersController( IAccount account,
                                IBandRepository bandRepository,
                                IUserRepository userRepository,
                                IValidationRules validationRules)
        {
            _account = account;
            _bandRepository = bandRepository;
            _userRepository = userRepository;
            _validationRules = validationRules;

            var currentUserName = GetCurrentSessionUser();
            if (currentUserName.Length > 0)
                _currentUser = account.GetUserByUserName(currentUserName);
            _common = new CommonSong(account, currentUserName);
        }
예제 #4
0
        public GigsController(  IBandRepository bandRepository,
                                IGigRepository gigRepository,
                                ISetlistRepository setlistRepository,
                                IValidationRules validationRules, 
                                IAccount account)
        {
            _bandRepository = bandRepository;
            _gigRepository = gigRepository;
            _setlistRepository = setlistRepository;
            _validationRules = validationRules;

            var currentUserName = GetCurrentSessionUser();
            if (currentUserName.Length > 0)
                _currentUser = account.GetUserByUserName(currentUserName);
            _common = new CommonSong(account, currentUserName);
        }
예제 #5
0
        public BandsController( IUserRepository userRepository,
                                IBandRepository bandRepository,
                                ISongRepository songRepository,
                                IMemberRepository memberRepository,
                                IValidationRules validationRules,
                                IAccount account)
        {
            _userRepository = userRepository;
            _bandRepository = bandRepository;
            _songRepository = songRepository;
            _memberRepository = memberRepository;
            _validationRules = validationRules;

            var currentUserName = GetCurrentSessionUser();
            if (currentUserName.Length > 0)
                _currentUser = account.GetUserByUserName(currentUserName);
            _common = new CommonSong(account, currentUserName);
        }
예제 #6
0
        public SetlistsController(  IBandRepository bandRepository, 
                                    ISetlistRepository setlistRepository,
                                    ISetSongRepository setSongRepository,
                                    ISongRepository songRepository,
                                    IGigRepository gigRepository, 
                                    IAccount account, 
                                    IValidationRules validationRules)
        {
            var currentUserName = GetCurrentSessionUser();
            _currentUser = (currentUserName.Length > 0) ? account.GetUserByUserName(currentUserName) : null;

            _bandRepository = bandRepository;
            _setlistRepository = setlistRepository;
            _setSongRepository = setSongRepository;
            _songRepository = songRepository;
            _gigRepository = gigRepository;
            _validationRules = validationRules;
            _common = new CommonSong(account, currentUserName);
        }
예제 #7
0
        private IList<UserPreferenceTableColumn> GetStartupUserPreferenceTableColumns(User u)
        {
            var columns = _tableColumnRepository.GetAll()
                .Where(x => x.Table.Id == Constants.UserTable.BandId);

            return columns.Select(c => new UserPreferenceTableColumn
                                           {
                                               User = u,
                                               TableColumn = c, 
                                               IsVisible = true
                                           }).ToList();
        }
예제 #8
0
        public long CreateUser(string username, string email, string password, string ip, string browser)
        {
            var u = new User
                {
                    UserName = username,
                    Email = email,
                    PasswordHash = GeneratePasswordHash(password.Trim()),
                    IPAddress = ip,
                    BrowserInfo = browser,
                    DateRegistered = DateTime.Now,
                    IsDisabled = false
                };

            var userPreferenceTableColumns = GetStartupUserPreferenceTableColumns(u);
            u.UserPreferenceTableColumns = userPreferenceTableColumns;

            return _userRepository.Add(u);
        }