Exemplo n.º 1
0
    protected void BuyOrUpgradePlan(PurchaseBalances balance)
    {
        try
        {
            var plan        = new InvestmentPlatformPlan(int.Parse(PlansDropDownList.SelectedValue));
            var activePlans = CurrentMode == InvestmentPlatformMode.Levels ? 0 : userActivePlans.Count;

            if (AppSettings.InvestmentPlatform.LevelsEnabled)
            {
                InvestmentLevelsManager.CanUserDepositOnLevel(plan, User);
            }

            if (plan.MaxPrice > Money.Zero)
            {
                if (AppSettings.InvestmentPlatform.InvestmentPlatformPlansPolicy == PlansPolicy.OneUpgradedPlan)
                {
                    throw new MsgException(U6012.CANTUPGRADERANGEPLAN);
                }

                var targetPrice = Money.Parse(RangePriceTextBox.Text);
                if (plan.CheckPlanPrice(targetPrice))
                {
                    InvestmentPlatformManager.BuyOrUpgradePlan(Member.Current, balance, plan, targetPrice);
                }
                else
                {
                    throw new MsgException(U6012.TYPECORRECTPRICE);
                }
            }
            else
            {
                InvestmentPlatformManager.BuyOrUpgradePlan(Member.Current, balance, plan);
            }

            //IF activePlans = 1, MEANS THAT WE UPGRADE PLAN (ON PlansPolicy.OneUpgradedPlan)
            if (AppSettings.InvestmentPlatform.InvestmentPlatformPlansPolicy == PlansPolicy.OneUpgradedPlan && activePlans == 1)
            {
                SuccessTextLiteral.Text = string.Format(U6011.SUCCESSUPGRADEPLAN, plan.Name);
            }
            else
            {
                SuccessTextLiteral.Text = string.Format(U6006.SUCCESBOUGHTPLAN, plan.Name);
            }

            SuccessPanel.Visible = true;

            availablePlans = InvestmentPlatformManager.GetAllAvailablePlansForUser(User.Id);
            InitBuyViewControls();
            InitPlans();
        }
        catch (Exception ex)
        {
            ErrorPanel.Visible    = true;
            ErrorTextLiteral.Text = ex.Message;
            if (!(ex is MsgException))
            {
                ErrorLogger.Log(ex);
            }
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.InvestmentPlatform.InvestmentPlatformEnabled);

        if (TitanFeatures.IsRofrique)
        {
            BuyOptionsPlaceHolder.Visible = false;
        }

        availablePlans = InvestmentPlatformManager.GetAllAvailablePlansForUser(User.Id);

        if (Request.QueryString["m"] != null)
        {
            MenuButton_Click(ManageButton, null);
        }

        SuccessPanel.Visible = false;
        ErrorPanel.Visible   = false;

        InitManageViewControls();

        if (!Page.IsPostBack)
        {
            InitBuyViewControls();
            if (CurrentMode == InvestmentPlatformMode.Levels)
            {
                LevelsGridView.Columns[0].HeaderText = U5007.LEVELS.ToUpper();
                LevelsGridView.Columns[1].HeaderText = U4200.DEPOSIT;
                LevelsGridView.Columns[2].HeaderText = U4000.EARNINGS;
                LevelsGridView.Columns[3].HeaderText = U6012.FEEFOREACHDEPOSIT;
                LevelsGridView.Columns[4].HeaderText = U6012.MAXIMUMTIMESADAY;
                LevelsGridView.Columns[5].HeaderText = U6013.AVAILABLEFROM;
                LevelsGridView.Columns[6].HeaderText = U6013.AVAILABLEWITHPP;
            }
        }

        InitPlans();
    }