示例#1
0
        private void Bind()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["gid"]))
            {
                phGuessWholeShowScore.Visible = true;
                
                Guid guessId = new Guid(Request.QueryString["gid"]);
                Guid userID = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());

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

                var guess = guessService.GetGuessWholeShow(guessId);

                TopicName = topicService.GetTopic(guess.TopicId).TopicName;

                if (guess.UserId == userID)
                {
                    var officialGuess = guessService.GetOfficialGuessByTopic(guess.TopicId);

                    if (officialGuess != null)
                    {
                        var score = guess.GetScore(officialGuess);

                        if (score != null)
                        {
                            lblGuessWholeShowScore.Text = score.GetScore().ToString();
                        }
                    }
                }
                else
                {
                    //Go buck f*****g wild on them
                }

                //WHEN OTHER GUESSES GET INTEGRATED INTO THIS PAGE THIS FUNCTIONALITY WILL NEED 
                // TO BE USED FOR EACH ONE SO WILL HAVE TO BE MOVED OUT
                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();
                }
            }

            
        }
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            ResetPanels();

            TopicService service = new TopicService(Ioc.GetInstance<ITopicRepository>());

            bool success = false;
            DateTime startDate;
            DateTime endDate;
            Guid? showType = null;
            Guid? tourType = null;
            TopicType t = TopicType.None;

            if (Validated(out startDate, out endDate))
            {
                if (ddlShowType.SelectedValue != "-1" && ddlTourType.SelectedValue == "-1")
                {
                    Guid g = new Guid(ddlShowType.SelectedValue);
                    showType = g;
                    t = TopicType.Show;
                }
                else if (ddlShowType.SelectedValue == "-1" && ddlTourType.SelectedValue != "-1")
                {
                    Guid g = new Guid(ddlTourType.SelectedValue);
                    tourType = g;
                    t = TopicType.Tour;
                }

                Topic topic = new Topic()
                {
                    TopicName = txtTopicName.Text.Trim(),
                    TopicId = Guid.NewGuid(),
                    StartDate = startDate,
                    EndDate = endDate,
                    Notes = txtNotes.Text.Trim(),
                    ShowId = showType,
                    TourId = tourType,
                    Type = (short)t
                };

                service.SaveCommit(topic, out success);
            }
        }
        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());
            }
        }
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            ResetPanels();

            TopicService tourService = new TopicService(Ioc.GetInstance<ITopicRepository>());
            SongService songService = new SongService(Ioc.GetInstance<ISongRepository>());
            SetService setService = new SetService(Ioc.GetInstance<ISetRepository>());
            SetSongService setSongService = new SetSongService(Ioc.GetInstance<ISetSongRepository>());

            bool success = false;
            bool compiledSuccess = true;

            if (string.IsNullOrEmpty(hdnId.Value))
            {
                Bind();
                return;
            }

            var set = (Set)setService.GetSet(new Guid(hdnId.Value));

            if (set == null)
            {
                Bind();
                return;
            }

            if (lstSongs.Items.Count <= 0)
            {
                Bind();
                return;
            }

            using (IUnitOfWork uow = TheCore.Infrastructure.UnitOfWork.Begin())
            {

                foreach (ListItem item in lstSongs.Items)
                {
                    if (!item.Selected) { continue; }

                    var song = songService.GetSong(new Guid(item.Value));

                    if (song == null) { continue; }

                    short? order = 1;

                    if (set.SetSongs.Count > 0)
                    {
                        order = set.SetSongs.OrderBy(x => x.Order).Last().Order;
                        order++;
                    }

                    SetSong setSong = new SetSong()
                        {
                            Album = song.Album,
                            CreatedDate = DateTime.UtcNow,
                            SetSongId = Guid.NewGuid(),
                            SongId = song.SongId,
                            SongName = song.SongName,
                            Order = order,
                            Set = set,
                            SetId = set.SetId,
                            Segue = chkSegue.Checked
                        };

                    setSongService.Save(setSong, out success);

                    compiledSuccess = compiledSuccess && success;
                }

                if (compiledSuccess)
                {
                    uow.Commit();
                    phSuccess.Visible = true;
                    phError.Visible = false;
                }
                else
                {
                    phError.Visible = true;
                    phSuccess.Visible = false;
                }
            }
            
            Bind();
        }
        private void SetupTopicList()
        {
            TopicService topicService = new TopicService(Ioc.GetInstance<ITopicRepository>());

            var topics = topicService.GetAllTopics().OrderByDescending(x => x.CreatedDate);

            foreach (var topic in topics)
            {
                ddlTopics.Items.Add(new ListItem(topic.TopicName, topic.TopicId.ToString()));
            }

            ListItem item = new ListItem("Please select a Topic", "-1");

            ddlTopics.Items.Insert(0, item);

            item.Selected = true;
        }