Exemple #1
0
    /// <summary>
    /// Check before submit request
    /// </summary>
    /// <returns></returns>
    public bool IsActiveAtTheMoment(Member user)
    {
        var  cards = GiftCard.GetActiveCards();
        bool isOK  = false;

        foreach (var card in cards)
        {
            var codes = GiftCode.GetActiveCodesForMember(user, card.Id);
            foreach (var code in codes)
            {
                if (code.Key.Id == this.Id)
                {
                    isOK = true;
                }
            }
        }

        return(isOK);
    }
Exemple #2
0
    protected Panel GeneratePanel(GiftCard giftcard)
    {
        Panel cardPanel = new Panel();

        cardPanel.ClientIDMode = System.Web.UI.ClientIDMode.Static;
        cardPanel.ID           = "cardPanel" + giftcard.Id;
        cardPanel.Attributes.Add("style", "display:none;");

        Image image = new Image();

        image.ImageUrl = giftcard.ImageUrl;
        cardPanel.Controls.Add(image); //Append it

        Literal lit1 = new Literal();

        lit1.Text = "<br/><h3>" + giftcard.Title + "</h3><br/>";

        var codes = GiftCode.GetActiveCodesForMember(Member.CurrentInCache, giftcard.Id);

        if (codes.Count > 0)
        {
            //Generate table
            lit1.Text += "<table class=\"exchangeTable\">";
            cardPanel.Controls.Add(lit1);

            foreach (var code in codes)
            {
                Literal lit2 = new Literal();
                lit2.Text = "<tr><td>" + U4000.EXCHANGENPFOR.Replace("%n%", "<b>" + code.Value + "</b>")
                            .Replace("%p%", AppSettings.PointsName).Replace("%w%", code.Key.Value) + "</td><td>";
                cardPanel.Controls.Add(lit2);

                Button button = new Button();
                button.CssClass        = "btn btn-inverse btn-xs";
                button.Text            = L1.SUBMIT;
                button.OnClientClick   = "hideList(" + giftcard.Id + ");";
                button.CommandArgument = code.Key.Id.ToString();
                button.Command        += button_Click;
                cardPanel.Controls.Add(button);

                //Register for AJAX
                ScriptManager scriptMan = ScriptManager.GetCurrent(this);
                scriptMan.RegisterAsyncPostBackControl(button);

                Literal lit3 = new Literal();
                lit3.Text = "</td></tr>";
                cardPanel.Controls.Add(lit3);
            }

            Literal lit4 = new Literal();
            lit4.Text = "</table><br /><br /><a href=\"#\" class=\"btn btn-danger\" onclick=\"hidePopupList(" + giftcard.Id + "); return false;\">"
                        + U4000.CANCEL + "</a>";
            cardPanel.Controls.Add(lit4);
        }
        else
        {
            lit1.Text += "<br/><i>" + U4000.THEREARENOCODES + "</i>";
            lit1.Text += "<br /><br /><a href=\"#\" class=\"btn btn-danger\" onclick=\"hidePopupList(" + giftcard.Id + "); return false;\">"
                         + U4000.CANCEL + "</a>";
            cardPanel.Controls.Add(lit1);
        }

        return(cardPanel);
    }