Exemplo n.º 1
0
        private GuessWholeShow CreateNewGuess(Guid showId, Guid topicId, Guid userId, out bool s)
        {
            GuessWholeShowService guessService = new GuessWholeShowService(Ioc.GetInstance <IGuessWholeShowRepository>());

            s = false;
            bool compiledSuccess = true;

            Guid setId            = CreateNewSet(showId, out s);
            Guid guessWholeShowId = Guid.NewGuid();

            compiledSuccess = compiledSuccess && s;

            GuessWholeShow newGuess = new GuessWholeShow()
            {
                GuessWholeShowId = guessWholeShowId,
                TopicId          = topicId,
                SetId            = setId,
                UserId           = userId
            };

            guessService.SaveCommit(newGuess, out s);

            compiledSuccess = compiledSuccess && s;

            return(newGuess);
        }
Exemplo n.º 2
0
        private void BindSet(GuessWholeShow guess)
        {
            lnkGetScore.NavigateUrl = LinkBuilder.GetScoreLink(guess.GuessWholeShowId, Request.Url.ToString());

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

            var set = (Set)setService.GetSet(guess.SetId);

            if (set != null)
            {
                rptSongList.DataSource = set.SetSongs.Where(x => x.Deleted == false).OrderBy(x => x.Order);
                rptSongList.DataBind();
            }

            lnkAddSongsToSet.NavigateUrl = LinkBuilder.AddSongsToSetControlLink(set.SetId, returnUrl);
            phAddSongs.Visible           = true;
        }
        private bool CreateGuess()
        {
            bool success = false;

            Guid setId;

            if (ddlSets.SelectedValue == "-1")
            {
                if (!string.IsNullOrEmpty(hdnSetId.Value))
                {
                    setId = new Guid(hdnSetId.Value);
                }
                else
                {
                    phNoSet.Visible = true;
                    return(false);
                }
            }
            else
            {
                setId = new Guid(ddlSets.SelectedValue);
            }

            Guid guessId = Guid.NewGuid();
            Guid topicId = new Guid(ddlTopics.SelectedValue);
            Guid userId  = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());

            GuessWholeShowService guessService = new GuessWholeShowService(Ioc.GetInstance <IGuessWholeShowRepository>());

            GuessWholeShow guess = new GuessWholeShow()
            {
                GuessWholeShowId = guessId,
                TopicId          = topicId,
                SetId            = setId,
                UserId           = userId,
                Official         = chkOfficial.Checked
            };

            guessService.SaveCommit(guess, out success);

            return(success);
        }
Exemplo n.º 4
0
        private void Bind()
        {
            Guid showId = new Guid(Request.QueryString["id"]);
            Guid userID = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());

            TopicService          topicService = new TopicService(Ioc.GetInstance <ITopicRepository>());
            GuessWholeShowService guessService = new GuessWholeShowService(Ioc.GetInstance <IGuessWholeShowRepository>());

            var topic = topicService.GetTopicByShow(showId);

            if (topic != null)
            {
                var guess = guessService.GetGuessWholeShowByTopicIdAndUserId(topic.TopicId, userID);

                if (guess != null)
                {
                    BindSet((GuessWholeShow)guess.First());
                }
                else
                {
                    bool s = false;

                    GuessWholeShow g = CreateNewGuess(showId, topic.TopicId, userID, out s);

                    if (!s)
                    {
                        Response.Redirect(LinkBuilder.PredictTourLink());
                    }
                    else
                    {
                        BindSet(g);
                    }
                }
            }
            else
            {
                Response.Redirect(LinkBuilder.PredictTourLink());
            }
        }