Beispiel #1
0
        public void btnApplyTag_Click(object sender, EventArgs e)
        {
            PromptHelper prompt;

            if (string.IsNullOrEmpty(hdnShowId.Value))
            {
                return;
            }

            if (ddlTags.SelectedValue == "-1")
            {
                prompt = new PromptHelper("Please choose a valid tag.");
                Page.RegisterStartupScript(prompt.ScriptName, prompt.GetErrorScript());
            }

            var showId = new Guid(hdnShowId.Value);

            var success = false;

            try {
                var tagId = new Guid(ddlTags.SelectedValue);

                var showTag = _DomainObjectFactory.CreateShowTag(showId, tagId, GetUserId());

                _ShowTagService.SaveCommit(showTag, out success);
            }
            catch (Exception ex) {
                _Log.WriteFatal("THERE WAS AN ERROR APPLYING A TAG ON NOTES.ASPX with message: " + ex.Message);
                success = false;
            }

            ValidateTags(success, "There was an error applying the tag.", showId);
        }
        protected void ShowError(string errorMessage)
        {
            var prompt      = new PromptHelper(errorMessage);
            var errorScript = prompt.GetErrorScript();

            Page.RegisterStartupScript("validateSuccess", errorScript);
        }
        public void btnCreateTag_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNewTagName.Text))
            {
                return;
            }

            HideShowList();
            var userId = GetUserId();

            var tag = _tagService.GetTag(txtNewTagName.Text.Trim(), userId);

            PromptHelper prompt;

            if (tag != null)
            {
                prompt = new PromptHelper("You already have a tag with the same name. Please choose it from your list or give it a new name.");
                Page.RegisterStartupScript(prompt.ScriptName, prompt.GetErrorScript());
                return;
            }

            var success = false;

            try {
                var newTag = _DomainObjectFactory.CreateTag(txtNewTagName.Text, userId);
                _tagService.SaveCommit(newTag, out success);
            }
            catch (Exception ex) {
                _Log.WriteFatal("THERE WAS AN ERROR SAVING A NEW TAG ON TAGS.ASPX with message: " + ex.Message);
                success = false;
            }

            Bind();
            ValidateSuccess(success, "You have saved your tag successfully.", "There was an error saving your tag.");
        }
        private void SearchUser(bool fromSubscribe)
        {
            var list = new List <LatestProfile>();

            //If there is no text then do not continue
            if (string.IsNullOrEmpty(txtUserName.Text))
            {
                //If it came from Subscribe then just reset to the default
                if (fromSubscribe)
                {
                    Bind();
                }
                //If it did NOT come from Subscribe then tell them to enter text to search on.
                else
                {
                    var prompt = new PromptHelper("Please enter the user name or part of the user name in order to search.");
                    Page.RegisterStartupScript(prompt.ScriptName, prompt.GetErrorScript());
                }

                return;
            }

            lblResultsType.Text = "User Name Search";
            phReset.Visible     = true;

            //Set search mode to true so that you know the user was searching on their last view
            hdnSearchMode.Value = "true";

            var profiles = ProfileService.GetProfilesLikeUserName(txtUserName.Text);

            var listenedShowService = Ioc.GetInstance <IListenedShowService>();
            var subscriptionService = Ioc.GetInstance <ISubscriptionService>();

            var subscriptions = subscriptionService.GetSubscriptionsByUser(GetUserId());

            foreach (var profile in profiles)
            {
                var userId = GetUserId(profile.UserName);
                var latest = listenedShowService.GetLatestByUserId(userId);

                if (latest != null)
                {
                    var showService = Ioc.GetInstance <IShowService>();
                    var show        = showService.GetShow(latest.ShowId);
                    var sub         = subscriptions.SingleOrDefault(x => x.SubscribedUserId == latest.UserId);

                    list.Add(new LatestProfile(latest, show, profile, sub));
                }
            }

            rptResults.DataSource = list;
            rptResults.DataBind();
        }
Beispiel #5
0
        private void ValidateTags(bool success, string error, Guid showId)
        {
            PromptHelper prompt;

            if (success)
            {
                BindTags(showId);
            }
            else
            {
                prompt = new PromptHelper(error);
                Page.RegisterStartupScript(prompt.ScriptName, prompt.GetErrorScript());
            }
        }
Beispiel #6
0
        public void btnCreateTag_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTagName.Text) || string.IsNullOrEmpty(hdnShowId.Value))
            {
                return;
            }

            var  userId = GetUserId();
            Guid showId = new Guid(hdnShowId.Value);

            ITagService tagService = Ioc.GetInstance <ITagService>();
            var         tag        = tagService.GetTag(txtTagName.Text.Trim(), userId);

            PromptHelper prompt;

            if (tag != null)
            {
                prompt = new PromptHelper("You already have a tag with the same name. Please choose it from your list or give it a new name.");
                Page.RegisterStartupScript(prompt.ScriptName, prompt.GetErrorScript());
                return;
            }

            var success = false;

            try {
                var tagName = txtTagName.Text;
                var newTag  = _DomainObjectFactory.CreateTag(tagName.Length > DEFAULT_MAX_TAG_NAME ? tagName.Substring(0, DEFAULT_MAX_TAG_NAME) : tagName, userId);
                var showTag = _DomainObjectFactory.CreateShowTag(showId, newTag.Id, GetUserId());

                using (IUnitOfWork uow = UnitOfWork.Begin()) {
                    tagService.Save(newTag, out success);

                    bool showTagSuccess = false;
                    _ShowTagService.Save(showTag, out showTagSuccess);

                    success = success && showTagSuccess;

                    if (success)
                    {
                        uow.Commit();
                    }
                }
            }
            catch (Exception ex) {
                _Log.WriteFatal("THERE WAS AN EXCEPTION SAVING A NEW TAG ON NOTES.ASPX with message: " + ex.Message);
                success = false;
            }

            ValidateTags(success, "There was an error saving your tag.", showId);
        }
Beispiel #7
0
        public string ValidateSuccess(bool success, string successMessage, string error)
        {
            PromptHelper prompt;

            if (success)
            {
                prompt = new PromptHelper(successMessage);
                return(prompt.GetSuccessScript());
            }
            else
            {
                prompt = new PromptHelper(error);
                return(prompt.GetErrorScript());
            }
        }
        private void Subscribe(string userName)
        {
            var user = _MembershipProvider.GetUser(userName);

            if (user == null)
            {
                return;
            }

            var subscribedUserId = new Guid(user.ProviderUserKey.ToString());
            var userId           = GetUserId();

            var subscription = _DomainObjectFactory.CreateSubscription(userId, subscribedUserId);

            var subscriptionService = Ioc.GetInstance <ISubscriptionService>();

            var success = false;

            subscriptionService.SaveCommit(subscription, out success);

            PromptHelper prompt;

            if (success)
            {
                if (hdnSearchMode.Value == "true")
                {
                    SearchUser(true);
                }
                else
                {
                    Bind();
                }

                prompt = new PromptHelper("You have successfully subscribed to that user's guide");
                Page.RegisterStartupScript(prompt.ScriptName, prompt.GetSuccessScript());
            }
            else
            {
                prompt = new PromptHelper("There was an error subscribing to that user.  Please try again later.");
                Page.RegisterStartupScript(prompt.ScriptName, prompt.GetErrorScript());
            }
        }
        public void btnSaveTagName_Click(object sender, EventArgs e)
        {
            if (Tutorial)
            {
                phPart3.Visible = true;
            }

            if (string.IsNullOrEmpty(txtTagName.Text))
            {
                PromptHelper prompt = new PromptHelper("Please choose a tag to edit");
                Page.RegisterStartupScript(prompt.ScriptName, prompt.GetErrorScript());
            }

            string previousColor = string.Empty;
            var    success       = false;

            try {
                var tagId = (Guid)ViewState["TagId"];

                using (IUnitOfWork uow = UnitOfWork.Begin()) {
                    var tag = _tagService.GetTag(tagId);
                    tag.Name      = txtTagName.Text;
                    tag.Color     = TagColors.GetColorByHex(ddlColor.SelectedValue).CssClass;
                    previousColor = ddlColor.SelectedValue;

                    uow.Commit();
                    success = true;
                }
            }
            catch (Exception ex) {
                _Log.WriteFatal("THERE WAS AN ERROR SAVING A TAG NAME ON TAGS.ASPX with message: " + ex.Message);
                success = false;
            }

            Bind();
            if (!string.IsNullOrEmpty(previousColor))
            {
                ddlColor.SelectedValue = previousColor;
            }

            ValidateSuccess(success, "You have successfully saved the new tag name.", "There was an error saving the new tag name.");
        }
Beispiel #10
0
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            PromptHelper prompt;

            if (string.IsNullOrEmpty(ddlCountry.SelectedValue))
            {
                prompt = new PromptHelper("Please choose a valid country.");
                Page.RegisterStartupScript(prompt.ScriptName, prompt.GetErrorScript());
                return;
            }

            bool success = false;

            try {
                DateTime showDate;
                var      parsed = DateTime.TryParse(txtShowDate.Text, out showDate);

                if (!parsed)
                {
                    prompt = new PromptHelper("Please enter a valid date for the show.");
                    Page.RegisterStartupScript(prompt.ScriptName, prompt.GetErrorScript());
                    return;
                }

                var show = _DomainObjectFactory.CreateShow(txtVenue.Text, txtCity.Text, ddlState.SelectedValue, ddlCountry.SelectedValue, txtNotes.Text, showDate);

                var showService = Ioc.GetInstance <IShowService>();

                showService.SaveCommit(show, out success);
            }
            catch (Exception ex) {
                _Log.WriteFatal("THERE WAS AN ERROR CREATING A SHOW IN CREATESHOW with message: " + ex.Message);
                success = false;
            }

            ValidateSuccess(success, "You have successfully saved the show.", "There was an error saving the show.");
        }