コード例 #1
0
        public SetBasedScore GetScore(GuessSetBased master)
        {
            SetBasedScore score = new SetBasedScore();

            int setIndex = 0;
            int songIndex = 0;

            ISet retSet;
            double scoreCount = 0;
            
            foreach (var set in master.SongList.Sets)
            {
                retSet = new Set();
                scoreCount = 0;

                setIndex = master.SongList.Sets.IndexOf(set);
                
                foreach (var song in set.Key.SongList)
                {
                   songIndex = set.Key.SongList.IndexOf(song);

                   var songPair = new KeyValuePair<ISong, SongNote>(song.Key, song.Value);

                   retSet.SongList.Add(songPair);

                   if (SongList.Sets[setIndex].Key.SongList[songIndex].Key.SongIsEqual(song.Key))
                   {
                       scoreCount += RightSongRightSpot;

                       var songNote = SongList.Sets[setIndex].Key.SongList[songIndex].Value;

                       if (songNote == SongNote.Into && songNote == song.Value)
                       {
                           scoreCount += IntoCorrect;
                       }
                       else if(songNote == SongNote.Into && songNote != song.Value)
                       {
                           scoreCount -= IntoWrong;
                       }
                   }
                   else if (SongList.Sets[setIndex].Key.ContainsSong(song.Key))
                   {
                       scoreCount += RightSongSameSet;
                   }
                   else
                   {
                       scoreCount -= WrongSong;
                   }
                }

                score.AddSet(retSet, scoreCount);
            }

            return score;
        }
コード例 #2
0
        public void lnkAddSetToShow_Click(object sender, EventArgs e)
        {
            ResetPanels();

            Guid showId = new Guid(hdnId.Value);

            SetService setService = new SetService(Ioc.GetInstance<ISetRepository>());

            var show = (Show)showService.GetShow(showId);
            bool success = false;

            if(show != null)
            {
                short? setNumber = (short)show.Sets.Count;
                setNumber++;

                Guid setId = Guid.NewGuid();

                Set set = new Set()
                {
                    CreatedDate = DateTime.UtcNow,
                    Encore = chkEncore.Checked,
                    SetId = setId,
                    SetNumber = setNumber,
                    ShowId = showId,
                    Official = true
                };

                setService.SaveCommit(set, out success);
            }

            if (success)
            {
                phSuccess.Visible = true;
                phError.Visible = false;
            }
            else
            {
                phSuccess.Visible = false;
                phError.Visible = true;
            }

            Bind();
        }
コード例 #3
0
        private void MoveSongDown(Guid g, SetSong song, Set set)
        {
            if (song.Order != set.SetSongs.OrderBy(x => x.Order).Last().Order)
            {
                var songAfter = (SetSong)setSongService.GetSetSong(set.SetSongs.Where(x => x.Order == song.Order + 1).First().SetSongId);

                song.Order++;
                songAfter.Order--;
            }
        }
コード例 #4
0
        private void RemoveSong(Guid g, SetSong song, Set set)
        {
            song.Deleted = true;
            song.DeletedDate = DateTime.Now;

            setSongService.Delete(song);

            var songList = set.SetSongs.Where(x => x.SetSongId != song.SetSongId).OrderBy(x => x.Order);

            short? order = 1;

            foreach (var s in songList)
            {
                s.Order = order;
                order++;
            }
        }
コード例 #5
0
        private void MoveSongUp(Guid g, SetSong song, Set set)
        {
            if (song.Order != 1)
            {
                var songBefore = (SetSong)setSongService.GetSetSong(set.SetSongs.Where(x => x.Order == song.Order - 1).First().SetSongId);

                song.Order--;
                songBefore.Order++;
            }
        }
コード例 #6
0
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            ResetPanels();

            bool success = false;
            Guid? showId;
            Guid setId = Guid.NewGuid();

            SetService service = new SetService(Ioc.GetInstance<ISetRepository>());

            if (Validated())
            {
                showId = ddlShows.SelectedValue != "-1" ? new Guid(ddlShows.SelectedValue) : EmptyGuid;

                short? setNum = ddlSetNumber.SelectedValue != "0" ? short.Parse(ddlSetNumber.SelectedValue) : (short)0;

                Set set = new Set()
                {
                    SetId = setId,
                    Encore = chkEncore.Checked,
                    Notes = txtNotes.Text.Trim(),
                    Official = chkOfficial.Checked,
                    SetNumber = setNum == 0 ? null : setNum,
                    ShowId = showId == EmptyGuid ? null : showId
                };
                
                service.SaveCommit(set, out success);
            }

            if (success)
            {
                phSuccess.Visible = true;
                phError.Visible = false;
                phAddSongs.Visible = true;
                lnkAddSongsToSet.NavigateUrl = LinkBuilder.AddSongsToSetControlLink(setId, returnUrl);
                lnkAddSetToGuess.NavigateUrl = LinkBuilder.AddSetToGuessLink(setId);
            }
            else
            {
                phError.Visible = true;
                phSuccess.Visible = false;
            }
            
        }
コード例 #7
0
        private Guid CreateNewSet(Guid showId, out bool success)
        {
            success = false;
            SetService setService = new SetService(Ioc.GetInstance<ISetRepository>());

            Guid setId = Guid.NewGuid();

            Set newSet = new Set()
            {
                SetId = setId,
                Encore = false,
                Official = false,
                SetNumber = 0,
                ShowId = showId
            };

            setService.Save(newSet, out success);

            return setId;
        }
コード例 #8
0
        private void RemoveSet(Set set, Show show, ref SetService setService)
        {
            set.Deleted = true;
            set.DeletedDate = DateTime.Now;

            setService.Delete(set);

            short? setNumber = 1;

            var setList = show.Sets.OrderBy(x => x.SetNumber).Where(x => x.SetId != set.SetId);

            foreach (var s in setList)
            {
                s.SetNumber = setNumber;
                setNumber++;
            }
        }
コード例 #9
0
        private void MoveSetUp(Set set, Show show, ref SetService setService)
        {
                if (set.SetNumber != 1)
                {
                    var setBefore = (Set)setService.GetSet(show.Sets.Where(x => x.SetNumber == set.SetNumber - 1).First().SetId);

                    set.SetNumber--;
                    setBefore.SetNumber++;
                }
        }
コード例 #10
0
        private void MoveSetDown(Set set, Show show, ref SetService setService)
        {
            if (set.SetNumber != show.Sets.OrderBy(x => x.SetNumber).Last().SetNumber)
            {
                var songAfter = (Set)setService.GetSet(show.Sets.Where(x => x.SetNumber == set.SetNumber + 1).First().SetId);

                set.SetNumber++;
                songAfter.SetNumber--;
            }
        }