예제 #1
0
    protected void CurrentUserBuyOfferGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[1].Text = L1.DATEADDED;
            e.Row.Cells[2].Text = L1.PRICE;
            e.Row.Cells[3].Text = U6010.TRANSACTIONVALUE;
            e.Row.Cells[4].Text = U6010.AMOUNTTOBUY;
            e.Row.Cells[5].Text = U6010.AMOUNTLEFT;
            e.Row.Cells[6].Text = L1.STATUS;
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var CurrentOffer = new CryptocurrencyTradeOffer(Int32.Parse(e.Row.Cells[0].Text));

            CryptocurrencyOfferStatus Status = (CryptocurrencyOfferStatus)Convert.ToInt32(e.Row.Cells[6].Text);

            e.Row.Cells[2].Text = String.Format("{0} / {1}", Money.Parse(e.Row.Cells[2].Text).ToString(), AppSettings.CryptocurrencyTrading.CryptocurrencyCode);
            e.Row.Cells[3].Text = String.Format("{0} - {1}", CurrentOffer.MinOfferValue, CurrentOffer.MaxOfferValue);
            e.Row.Cells[4].Text = CryptocurrencyMoney.Parse(e.Row.Cells[4].Text).ToString();
            e.Row.Cells[5].Text = CryptocurrencyMoney.Parse(e.Row.Cells[5].Text).ToString();
            e.Row.Cells[6].Text = HtmlCreator.GetColoredStatus(Status);

            if (Status != CryptocurrencyOfferStatus.Paused)
            {
                e.Row.Cells[7].Text = " ";
            }

            if (Status != CryptocurrencyOfferStatus.Active)
            {
                e.Row.Cells[8].Text = " ";
            }
        }
    }
예제 #2
0
    protected void CurrentUserTransactionsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[1].Text = L1.AMOUNT;
            e.Row.Cells[2].Text = U6010.EXECUTIONTIME;
            e.Row.Cells[3].Text = L1.STATUS;
            e.Row.Cells[5].Text = U4200.TIMELEFT;
            e.Row.Cells[6].Text = L1.DESCRIPTION;
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //Loading data for addiotional info
            var CurrentTransaction = new CryptocurrencyTradeTransaction(Int32.Parse(e.Row.Cells[0].Text));
            var CurrentOffer       = new CryptocurrencyTradeOffer(CurrentTransaction.OfferId);

            e.Row.Cells[1].Text = CryptocurrencyMoney.Parse(e.Row.Cells[1].Text).ToString();

            if ((CryptocurrencyTransactionStatus)Int32.Parse(e.Row.Cells[3].Text) == CryptocurrencyTransactionStatus.AwaitingPaymentConfirmation)
            {
                e.Row.Cells[6].Visible = true;
            }
            else
            {
                e.Row.Cells[6].Visible = false;
            }
            e.Row.Cells[3].Text = HtmlCreator.GetColoredTransactionStatus((CryptocurrencyTransactionStatus)Int32.Parse(e.Row.Cells[3].Text));

            //Count Time Left in Escrow
            DateTime ExecutionTime   = DateTime.Parse(e.Row.Cells[2].Text);
            TimeSpan TimeLeft        = AppSettings.ServerTime - ExecutionTime;
            int      TimeLeftMinutes = CurrentOffer.EscrowTime - (int)TimeLeft.TotalMinutes;
            if (TimeLeftMinutes < 0)
            {
                TimeLeftMinutes = 0;
            }

            Label OfferTimeLeftToPayTextBox = new Label();
            OfferTimeLeftToPayTextBox.Text = HtmlCreator.GetColoredTime(TimeLeftMinutes);
            e.Row.Cells[5].Controls.Add(OfferTimeLeftToPayTextBox);

            //Load Description for this offerAddToCryptocurrencyBalance
            Label OfferDescriptionTextBox = new Label();

            //If seller description have data, that means that it is 100% buy offer and tehre is no desc, we have to load seller's description
            if (String.IsNullOrEmpty(CurrentTransaction.SellerDescription) || String.IsNullOrWhiteSpace(CurrentTransaction.SellerDescription))
            {
                OfferDescriptionTextBox.Text = CurrentOffer.Description;
            }
            else
            {
                OfferDescriptionTextBox.Text = CurrentTransaction.SellerDescription;
            }

            OfferDescriptionTextBox.CssClass = "description-column displaynone";
            e.Row.Cells[4].Controls.Add(OfferDescriptionTextBox);
        }
    }
예제 #3
0
        public static void Remove(int userId, CryptocurrencyMoney amount, CryptocurrencyType code)
        {
            var userBalance = GetObject(userId, code);
            if (userBalance.Balance - amount < new CryptocurrencyMoney(code, 0))
                throw new Exception(String.Format(U6010.ERRORREMOVECRYPTOCURRENCYBALANCE, amount, userId, userBalance.Balance));

            userBalance.Balance -= amount;
            userBalance.Save(); 
        }
예제 #4
0
    protected void WithdrawCryptocurrencyButton_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            CryptocurrencySuccessMessagePanel.Visible = false;
            CryptocurrencyErrorMessagePanel.Visible   = false;

            try
            {
                var Cryptocurrency = CryptocurrencyFactory.Get(SelectedCryptocurrency);

                User.ValidatePIN(CryptoPINTextBox.Text);

                string address = TryGetWithdrawalAddress(Cryptocurrency);

                Money   moneyAmount            = Money.Zero;
                Money   moneyFee               = Money.Zero;
                Money   totalAmount            = Money.Zero;
                decimal amountInCryptocurrency = Decimal.Zero;

                if (Cryptocurrency.WithdrawalFeePolicy == WithdrawalFeePolicy.Packs)
                {
                    WithdrawalPacksPlaceHolder.Visible = true;
                    WithdrawalPacksLiteral.Text        = BitcoinWithdrawalFeePacks.GetPacksText(User.Id);
                }

                moneyAmount            = new Money(Convert.ToDecimal(WithdrawCryptocurrencyAmountTextBox.Text)).FromMulticurrency();
                moneyFee               = Cryptocurrency.EstimatedWithdrawalFee(amountInCryptocurrency, address, User.Id, Cryptocurrency.WithdrawalSource);
                totalAmount            = moneyAmount - moneyFee;
                amountInCryptocurrency = Cryptocurrency.ConvertFromMoney(moneyAmount);

                if (Cryptocurrency.WithdrawalSource == WithdrawalSourceBalance.Wallet)
                {
                    amountInCryptocurrency = Convert.ToDecimal(WithdrawCryptocurrencyAmountTextBox.Text);
                    moneyAmount            = new CryptocurrencyMoney(Cryptocurrency.Type, amountInCryptocurrency);
                    moneyFee    = Cryptocurrency.EstimatedWithdrawalFee(amountInCryptocurrency, address, User.Id, Cryptocurrency.WithdrawalSource);
                    totalAmount = new CryptocurrencyMoney(SelectedCryptocurrency, moneyAmount.ToDecimal() - moneyFee.ToDecimal());
                }

                TryValidateCryptocurrencyWithdrawalByEmailOrPhone();

                CryptocurrencyFeeLiteral.Visible = WithdrawTotalCryptocurrencyLiteral.Visible = true;
                CryptocurrencyFeeLiteral.Text    = "</br>" + U3500.CASHOUT_FEES + ": " + moneyFee.ToString() + "</br>";

                WithdrawTotalCryptocurrencyLiteral.Text     = "<b>" + U5001.TOTAL + ": " + totalAmount + "</b>";
                WithdrawCryptocurrencyButton.Visible        = false;
                WithdrawCryptocurrencyConfirmButton.Visible = true;
                WithdrawCryptocurrencyAmountTextBox.Enabled = false;
                CryptoPINTextBox.Enabled = false;
            }
            catch (Exception ex)
            {
                CryptocurrencyErrorMessagePanel.Visible = true;
                CryptocurrencyErrorMessageLiteral.Text  = ex.Message;
            }
        }
    }
예제 #5
0
        private void ValidateWithdrawal(Member user, string userAddress, decimal amount, WithdrawalSourceBalance withdrawalSource)
        {
            if (!WithdrawalEnabled)
            {
                throw new MsgException("Withdrawal is currently disabled by the administrator");
            }

            if (CryptocurrencyApi.IsAdministratorAddress(userAddress, WithdrawalApiProcessor))
            {
                throw new MsgException("You can't withdraw to administrator-generated address.");
            }

            Money  amountInCorrectType = Money.Zero;
            string errorMessage        = String.Empty;

            //General validation
            PayoutManager.ValidatePayoutNotConnectedToAmount(user);

            //Amounts & Balances
            if (withdrawalSource == WithdrawalSourceBalance.MainBalance)
            {
                amountInCorrectType = new Money(amount);

                //Check the balance
                if (amountInCorrectType > user.MainBalance)
                {
                    throw new MsgException(L1.NOTENOUGHFUNDS);
                }

                PayoutManager.ValidatePayout(user, amountInCorrectType);
                PayoutManager.CheckMaxPayout(CryptocurrencyTypeHelper.ConvertToPaymentProcessor(CryptocurrencyType), user, amountInCorrectType);
            }
            else //Wallets
            {
                amountInCorrectType = new CryptocurrencyMoney(this.Type, amount);

                //Check the balance
                if (amountInCorrectType > user.GetCryptocurrencyBalance(CryptocurrencyType))
                {
                    throw new MsgException(string.Format(U6012.NOFUNDSINWALLET, CryptocurrencyType.ToString()));
                }
            }

            //Check MIN withdrawal
            if (amountInCorrectType < GetMinimumWithdrawalAmount(user, withdrawalSource))
            {
                throw new MsgException(U5003.WITHDRAWALMUSTBEHIGHER);
            }

            //Check MAX withdrawals
            if (amountInCorrectType > GetMaximumWithdrawalAmount(user, withdrawalSource, out errorMessage))
            {
                throw new MsgException(errorMessage);
            }
        }
예제 #6
0
    protected void AddSellOfferButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (String.IsNullOrEmpty(SellAmountTextBox.Text) || decimal.Parse(SellAmountTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0}{1}{2}", U6010.AMOUNTTOBUY, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MinPriceTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0} {1}{2}{3}", U6010.PRICEPER, AppSettings.CryptocurrencyTrading.CryptocurrencyCode, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MaxOfferValueTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0}{1}{2}", U6010.CCMAXOFFERVALUE, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MinOfferValueTextBox.Text) > decimal.Parse(MaxOfferValueTextBox.Text))
            {
                throw new MsgException(String.Format("{0} {1}{2}{3}", U6010.CCMINOFFERVALUE, U6010.CANTBEHIGHER, U6010.CCMAXOFFERVALUE, "<br />"));
            }

            var User        = Member.CurrentInCache;
            var UserBalance = User.GetCryptocurrencyBalance(CryptocurrencyType.BTC);

            if (CryptocurrencyMoney.Parse(SellAmountTextBox.Text) > UserBalance)
            {
                throw new MsgException(String.Format(U6010.NOCREDITS_CRYPTOCURRENCYBALANCE, UserBalance));
            }

            CryptocurrencyTradeOffer.CreateNewOffer(CryptocurrencyOfferType.Sell,
                                                    Member.CurrentId,
                                                    Money.Parse(MinPriceTextBox.Text),
                                                    Money.Zero,
                                                    Money.Parse(MinOfferValueTextBox.Text),
                                                    Money.Parse(MaxOfferValueTextBox.Text),
                                                    Int32.Parse(EscrowTimeTextBox.Text),
                                                    Description = DescriptionTextBox.Text,
                                                    CryptocurrencyMoney.Parse(SellAmountTextBox.Text, CryptocurrencyType.BTC));

            Response.Redirect("~/user/cctrading/sell.aspx?SelectedTab=2");
        }
        catch (MsgException ex)
        {
            CreateSellErrorPanel.Visible = true;
            CreateSellErrorLiteral.Text  = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
예제 #7
0
    public static void CreateNewTemplate(int offerId, int buyerID, int sellerId, CryptocurrencyMoney cryptocurrencyAmount)
    {
        CryptocurrencyFinishedTradeOffer NewFinishedTrade = new CryptocurrencyFinishedTradeOffer()
        {
            OfferId       = offerId,
            BuyerId       = buyerID,
            SellerId      = sellerId,
            Rating        = CryptocurrencyOfferRating.Null,
            CCAmount      = cryptocurrencyAmount,
            BuyerComment  = String.Empty,
            SellerComment = String.Empty
        };

        NewFinishedTrade.Save(true);
    }
예제 #8
0
    protected void AllSellOffersGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var    CurrentOffer = new CryptocurrencyTradeOffer(Int32.Parse(e.Row.Cells[0].Text));
            Member User         = new Member(Int32.Parse(e.Row.Cells[1].Text));

            e.Row.Cells[1].Text = String.Format("<span style=\"float:left; margin-right: 10px\">{0}</span>{1}",
                                                HtmlCreator.CreateAvatarPlusUsername(User),
                                                CryptocurrencyPlatformManager.GetHtmlRatingStringForUser(User.Id));

            e.Row.Cells[3].Text = String.Format("<b>{0}</b>/{1}", Money.Parse(e.Row.Cells[3].Text).ToString(), AppSettings.CryptocurrencyTrading.CryptocurrencyCode);
            e.Row.Cells[4].Text = CurrentOffer.MinOfferValue + " - " + CurrentOffer.MaxOfferValue;
            e.Row.Cells[5].Text = CryptocurrencyMoney.Parse(e.Row.Cells[5].Text).ToString();
        }
    }
예제 #9
0
    protected void AddBuyOfferButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (decimal.Parse(BuyAmountTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0}{1}{2}", U6010.AMOUNTTOBUY, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MaxPriceTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0} {1}{2}{3}", U6010.PRICEPER, AppSettings.CryptocurrencyTrading.CryptocurrencyCode, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MaxOfferValueTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0}{1}{2}", U6010.CCMAXOFFERVALUE, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MinOfferValueTextBox.Text) > decimal.Parse(MaxOfferValueTextBox.Text))
            {
                throw new MsgException(String.Format("{0} {1}{2}{3}", U6010.CCMINOFFERVALUE, U6010.CANTBEHIGHER, U6010.CCMAXOFFERVALUE, "<br />"));
            }

            CryptocurrencyTradeOffer.CreateNewOffer(
                CryptocurrencyOfferType.Buy,
                Member.CurrentId,
                Money.Zero,
                Money.Parse(MaxPriceTextBox.Text),
                Money.Parse(MinOfferValueTextBox.Text),
                Money.Parse(MaxOfferValueTextBox.Text),
                Int32.Parse(EscrowTimeTextBox.Text),
                Description = String.Empty,
                CryptocurrencyMoney.Parse(BuyAmountTextBox.Text, CryptocurrencyType.BTC));

            Response.Redirect("~/user/cctrading/buy.aspx?SelectedTab=2");
        }
        catch (MsgException ex)
        {
            CreateBuyErrorPanel.Visible = true;
            CreateBuyErrorLiteral.Text  = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
예제 #10
0
    protected void SellOfferButton_OnClick(object sender, EventArgs e)
    {
        try
        {
            if (Request.Params.Get("oid") != null)
            {
                var SelectedOffer = new CryptocurrencyTradeOffer(Convert.ToInt32(Request.Params.Get("oid")));

                //Because when creating buy offer you don't create description, seller have to provide necessary info for buyer
                String AdditionalDescription = InfoForBuyerForOnClickSellTextBox.Text;

                if (CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) == CryptocurrencyMoney.Zero)
                {
                    throw new MsgException(U6011.CANTSELLZEROCRYPTOCURRENCY);
                }

                //Check if seller don't try sell more than expected
                if ((CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) > SelectedOffer.AmountLeft) ||
                    (CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) * SelectedOffer.MaxPrice > SelectedOffer.MaxOfferValue))
                {
                    throw new MsgException(U6010.ERRORTRYSELLMORE);
                }

                if (CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) * SelectedOffer.MaxPrice < SelectedOffer.MinOfferValue)
                {
                    throw new MsgException(U6010.ERRORTRYSELLLESS);
                }

                CryptocurrencyPlatformManager.TryPlaceOrder(SelectedOffer.Id, CryptocurrencyMoney.Parse(AmountToSellTextBox.Text, CryptocurrencyType.BTC), AdditionalDescription);

                Response.Redirect("~/user/cctrading/sell.aspx?SelectedTab=2");
            }
        }
        catch (MsgException ex)
        {
            SellErrorPanel.Visible = true;
            SellError.Text         = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
예제 #11
0
    protected void BuyOfferButton_OnClick(object sender, EventArgs e)
    {
        try
        {
            if (Request.Params.Get("oid") != null)
            {
                int ProductId     = Convert.ToInt32(Request.Params.Get("oid"));
                var SelectedOffer = new CryptocurrencyTradeOffer(ProductId);

                if (CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) == CryptocurrencyMoney.Zero)
                {
                    throw new MsgException(U6011.CANTBUYZEROCRYPTOCURRENCY);
                }

                if ((CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) > SelectedOffer.AmountLeft) ||
                    (CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) * SelectedOffer.MinPrice > SelectedOffer.MaxOfferValue))
                {
                    throw new MsgException(U6010.ERRORTRYBUYMORE);
                }

                if (CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) * SelectedOffer.MinPrice < SelectedOffer.MinOfferValue)
                {
                    throw new MsgException(U6010.ERRORTRYBUYLESS);
                }

                CryptocurrencyPlatformManager.TryPlaceOrder(ProductId, CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text, CryptocurrencyType.BTC), String.Empty);

                Response.Redirect("~/user/cctrading/buy.aspx?SelectedTab=2");
            }
        }
        catch (MsgException ex)
        {
            BuyErrorPanel.Visible = true;
            BuyError.Text         = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
예제 #12
0
 public static void Add(int userId, CryptocurrencyMoney amount, CryptocurrencyType code)
 {
     var userBalance = GetObject(userId, code);
     userBalance.Balance += amount;
     userBalance.Save();
 }
예제 #13
0
 public static void Set(int userId, CryptocurrencyType code, CryptocurrencyMoney value)
 {
     var userBalance = GetObject(userId, code);
     userBalance.Balance = value;
     userBalance.Save();
 }
예제 #14
0
파일: Balances.cs 프로젝트: dovanduy/titan
 private void SubtractFromCryptocurrencyBalance(CryptocurrencyType cryptocurrencyType, CryptocurrencyMoney value, string note, BalanceLogType logType = BalanceLogType.Other)
 {
     UserCryptocurrencyBalance.Remove(this.Id, value, cryptocurrencyType);
     //Works on ONE crypto balance at the moment
     BalanceLog.Add(this, CryptocurrencyTypeHelper.ConvertToBalanceType(cryptocurrencyType), value.ToDecimal() * -1, note, logType);
 }
예제 #15
0
    protected void SetupSpecialTransfersProperties()
    {
        AdditionalInformationLiteralPlaceHolder.Visible = false;
        PaymentConversionPlaceHolder.Visible            = false;
        CalculatePlaceHolder.Visible = false;

        RequestedBTCCryptocurrencyTransfer = false;
        CurrencyTransferSignLiteral.Text   = AppSettings.Site.MulticurrencySign;

        TransferFromTextBox.Text = AppSettings.Payments.CurrencyMode == CurrencyMode.Cryptocurrency? "0.1" : "100.00";

        if (RadioFrom.SelectedValue == "Main balance" && RadioTo.SelectedValue == TokenCryptocurrency.Code + " Wallet")
        {
            AdditionalInformationLiteral.Text = string.Format("1 {0} = <b>{1}</b>",
                                                              TokenCryptocurrency.Code, TokenCryptocurrency.GetValue().ToString());

            if (TitanFeatures.IsTrafficThunder)
            {
                AdditionalInformationLiteral.Text = string.Format("1 {0} = <b>${1}</b>",
                                                                  TokenCryptocurrency.Code, TokenCryptocurrency.GetValue().ToShortClearString());
            }

            if (!string.IsNullOrEmpty(AdditionalInformationLiteral.Text))
            {
                AdditionalInformationLiteralPlaceHolder.Visible = true;
            }
        }

        if (RadioTo.SelectedValue == "BTC Wallet" || RadioTo.SelectedValue == "BTC" ||
            RadioFrom.SelectedValue == "CoinPayments" || RadioFrom.SelectedValue == "CoinBase" || RadioFrom.SelectedValue == "Blocktrail")
        {
            if (AppSettings.Site.CurrencyCode != "BTC")
            {
                AdditionalInformationLiteral.Text = string.Format("1 BTC = <b>{0}</b>", BtcCryptocurrency.GetValue().ToString());
            }

            if (TitanFeatures.IsTrafficThunder)
            {
                AdditionalInformationLiteral.Text = "1 BTC = <b>" + String.Format(new System.Globalization.CultureInfo("en-US"), "{0:n2}", CryptocurrencyFactory.Get(CryptocurrencyType.BTC).GetOriginalValue("USD").ToDecimal()) + " USD</b>";
            }

            if (BtcCryptocurrency.DepositEnabled && BtcCryptocurrency.DepositMinimum > 0)
            {
                if (!string.IsNullOrEmpty(AdditionalInformationLiteral.Text))
                {
                    AdditionalInformationLiteral.Text += "<br /><br />";
                }

                AdditionalInformationLiteral.Text += String.Format(U6012.WARNINGMINBTCDEPOSIT, CryptocurrencyMoney.Parse(BtcCryptocurrency.DepositMinimum.ToString(), CryptocurrencyType.BTC).ToString());

                if (RadioFrom.SelectedValue == "CoinPayments")
                {
                    AdditionalInformationLiteral.Text += " " + U6012.BTCDEPOSITLIMITINFO;
                }
            }

            if (!string.IsNullOrEmpty(AdditionalInformationLiteral.Text))
            {
                AdditionalInformationLiteralPlaceHolder.Visible = true;
            }
        }

        if (RadioTo.SelectedValue == TransferOptionConst.PointsTransfer)
        {
            SetupDepositToPoints();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PointConversion", "pointConversion();", true);
        }

        if (RadioTo.SelectedValue == "BTC Wallet")
        {
            RequestedBTCCryptocurrencyTransfer = true;
            CurrencyTransferSignLiteral.Text   = "฿";
            TransferFromTextBox.Text           = "0.1";
        }
    }
예제 #16
0
    protected void btnTransfer_Click(object sender, EventArgs e)
    {
        ErrorMessagePanel.Visible = false;
        ErrorMessage.Text         = "";
        MessageUpdatePanel.Update();

        string amount = TransferFromTextBox.Text.Trim().Replace(",", ".");
        Money  Amount;

        try
        {
            Amount = Money.Parse(amount).FromMulticurrency();

            //Direct BTC transfer. BTC -> BTC Wallet
            if (RequestedBTCCryptocurrencyTransfer)
            {
                Amount = new CryptocurrencyMoney(CryptocurrencyType.BTC, Decimal.Parse(amount));
            }

            Member User = Member.Current;

            var HtmlResponse  = false;
            var ResultMessage = TransferHelper.TryInvokeTransfer(RadioFrom.SelectedValue, RadioTo.SelectedValue, Amount, User, ref HtmlResponse);

            if (ResultMessage == U3501.TRANSFEROK)
            {
                Response.Redirect("../status.aspx?type=transferok");
            }
            else
            {
                //It was a payment processor transfer
                btnTransfer.Visible = false;

                //MPesa Sapama?
                if (RadioFrom.SelectedValue == "MPesaAgent")
                {
                    Response.Redirect("~/user/deposit.aspx?mpesa=" + Amount.ToClearString());
                }

                PaymentAmountLabel.Text = L1.AMOUNT + ": <b>" + Amount.ToString() + "</b>";

                if (RadioFrom.SelectedValue == BtcCryptocurrency.DepositApiProcessor.ToString())
                {
                    PaymentFeeLabel.Visible           = false;
                    PaymentAmountWithFeeLabel.Visible = false;
                }
                else
                {
                    var gateway = PaymentAccountDetails.GetFirstGateway(RadioFrom.SelectedValue, true);

                    if (gateway == null)
                    {
                        throw new MsgException("No specified gateway installed.");
                    }

                    Amount = gateway.CalculateAmountWithFee(Amount);
                    PaymentFeeLabel.Text           = U3500.CASHOUT_FEES + ": <b>" + gateway.StaticFee.ToString() + "</b> + <b>" + gateway.PercentFee + "%</b>";
                    PaymentAmountWithFeeLabel.Text = L1.AMOUNT + " + " + U3500.CASHOUT_FEES + " = <b>" + Amount.ToString() + "</b>";

                    PaymentFeeLabel.Visible           = true;
                    PaymentAmountWithFeeLabel.Visible = true;
                }

                PaymentAmountLabel.Visible = true;
                transferInputRow.Visible   = false;
                dropdownlistsRow.Visible   = false;
                PaymentButtons.Text        = ResultMessage;
            }
        }
        catch (MsgException ex)
        {
            ShowErrorMessage(ex.Message);
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex);
            ShowErrorMessage(ex.Message);
        }
    }
예제 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.MoneyTransferEnabled);

        user = Member.Current;
        AppSettings.Reload();

        BtcCryptocurrency   = CryptocurrencyFactory.Get <BitcoinCryptocurrency>();
        EthCryptocurrency   = CryptocurrencyFactory.Get <EthereumCryptocurrency>();
        XrpCryptocurrency   = CryptocurrencyFactory.Get <RippleCryptocurrency>();
        TokenCryptocurrency = CryptocurrencyFactory.Get <RippleCryptocurrency>();

        DepositButton.Visible = AppSettings.Representatives.RepresentativesHelpDepositEnabled;

        if (!Page.IsPostBack)
        {
            if (BtcCryptocurrency.DepositEnabled)
            {
                BTCButton.Visible = !CryptocurrencyApiFactory.GetDepositApi(BtcCryptocurrency).AllowToUsePaymentButtons();

                if (TitanFeatures.IsRofriqueWorkMines)
                {
                    BTCButton.Text = "BTC Deposits";
                }
                else
                {
                    BTCButton.Text = "BTC";
                }
            }

            if (TitanFeatures.IsFlotrading)
            {
                BalanceButton.CssClass        = "";
                BTCButton.CssClass            = "ViewSelected";
                MenuMultiView.ActiveViewIndex = 1;
            }

            if (TitanFeatures.IsTrafficThunder)
            {
                UserBalancesPlaceHolder.Visible = false;
            }

            AppSettings.Reload();

            LangAdder.Add(DepositButton, U6010.DEPOSITVIAREPRESENTATIVE);
            LangAdder.Add(btnTransfer, L1.TRANSFER);
            LangAdder.Add(DepositViaRepresentativeButton, U6010.SENDTRANSFERMESSAGE);
            LangAdder.Add(MPesaConfirmButton, L1.CONFIRM);
            LangAdder.Add(BTCAmountRequiredFieldValidator, U2502.INVALIDMONEYFORMAT);
            LangAdder.Add(CalculatePointsValueButton, U6007.CALCULATE);

            //MPesa?
            if (Request.QueryString["mpesa"] != null)
            {
                StandardTransferPlaceHolder.Visible = false;
                MPesaTransferPlaceHolder2.Visible   = true;
                var gateway = PaymentAccountDetails.GetFirstIncomeGateway <MPesaSapamaAccountDetails>();
                MPesaAmount.Text = String.Format(U6005.TODEPOSITVIAMPESA, gateway.Username, gateway.Username,
                                                 Money.Parse(Request.QueryString["mpesa"]).ToString());
            }

            //Pre-selected tab
            if (Request.QueryString["button"] != null)
            {
                var button = (Button)MenuButtonPlaceHolder.FindControl("Button" + Request.QueryString["button"]);
                MenuButton_Click(button, null);
            }

            RadioFrom.Items.AddRange(GenerateHTMLButtons.DepositBalanceFromItems);

            if (TitanFeatures.IsRofriqueWorkMines && !CryptocurrencyApiFactory.GetDepositApi(BtcCryptocurrency).AllowToUsePaymentButtons())
            {
                RadioFrom.Items.Add(new ListItem("", "BTC"));
            }

            BTCTo.Items.AddRange(GenerateHTMLButtons.BTCToItems);

            if (BtcCryptocurrency.DepositEnabled)
            {
                BTCValueLabel.Text    = ClassicBTCValueLabel.Text = string.Format("<p class='alert alert-info'>{0}: <b>{1}</b></p>", U5003.ESTIMATEDBTCVALUE, BtcCryptocurrency.GetValue().ToString());
                BTCValueLabel.Visible = ClassicBTCValueLabel.Visible = AppSettings.Site.CurrencyCode != "BTC"; //We don't want to show 1B = 1B

                BTCPointsFrom.Items.AddRange(GenerateHTMLButtons.BTCFromItems);

                BTCPointsFrom.SelectedIndex = 0;

                if (BTCPointsFrom.SelectedValue == "Wallet")
                {
                    btnDepositBTC.Visible = true;

                    if (BtcCryptocurrency.DepositTarget == DepositTargetBalance.PurchaseBalance)
                    {
                        BTCTo.SelectedValue = "AdBalance";
                    }
                    else if (BtcCryptocurrency.DepositTarget == DepositTargetBalance.CashBalance)
                    {
                        BTCTo.SelectedValue = "CashBalance";
                    }
                    else if (BtcCryptocurrency.DepositTarget == DepositTargetBalance.Wallet)
                    {
                        BTCTo.SelectedValue = "BTCWallet";
                    }
                }

                BTCButtonPanel.Visible  = CryptocurrencyApiFactory.GetDepositApi(BtcCryptocurrency).AllowToUsePaymentButtons();
                ClassicBTCPanel.Visible = !CryptocurrencyApiFactory.GetDepositApi(BtcCryptocurrency).AllowToUsePaymentButtons();
            }

            if (((AppSettings.Payments.CommissionToMainBalanceEnabled && !TitanFeatures.UserCommissionToMainBalanceEnabled) ||
                 (TitanFeatures.UserCommissionToMainBalanceEnabled && user.CommissionToMainBalanceEnabled) ||
                 TitanFeatures.IsRevolca) && user.CheckAccessCustomizeTradeOwnSystem)
            {
                RadioTo.Items.Add(new ListItem("", "Main balance"));
            }

            if (!AppSettings.Payments.CashBalanceEnabled)
            {
                ListItem cb = RadioTo.Items.FindByValue("Cash balance");
                if (cb != null)
                {
                    RadioTo.Items.Remove(cb);
                }
            }

            if (!AppSettings.Payments.MarketplaceBalanceEnabled)
            {
                ListItem cb = RadioTo.Items.FindByValue("Marketplace balance");
                if (cb != null)
                {
                    RadioTo.Items.Remove(cb);
                }
            }

            SetRadioToValues();
            SetProcessorValues();
            SetupSpecialTransfersProperties();

            if (RadioFrom.Items.Count == 0 || RadioTo.Items.Count == 0)
            {
                //No transfers available
                transferInputRow.Visible = false;
                TransferSameCommissionToMainLiteral.Visible = true;
                TransferSameCommissionToMainLiteral.Text    = U5006.NOTRANSFEROPTIONS;
                transfertable.Visible = false;
            }

            if (TitanFeatures.IsTradeOwnSystem)
            {
                //Checking condition to display appropriate message
                if (!user.CheckAccessCustomizeTradeOwnSystem && user.CommissionToMainBalanceRequiredViewsMessageInt > 0)
                {
                    CommissionTransferInfoDiv.Visible = true;
                    CommissionTransferInfo.Text       = String.Format(U6010.COMMISSIONBALANCETRANSFERINFO, user.CommissionToMainBalanceRequiredViewsMessageInt, AppSettings.RevShare.AdPack.AdPackName);
                }
                else if (!user.CheckAccessCustomizeTradeOwnSystem && user.CommissionToMainBalanceRequiredViewsMessageInt == 0)
                {
                    CommissionTransferInfoDiv.Visible = true;
                    CommissionTransferInfo.Text       = String.Format(U6010.COMMISSIONBALANCETRANSFERNOACTIVEADPACKINFO, AppSettings.RevShare.AdPack.AdPackName);
                }
                else
                {
                    CommissionTransferInfoDiv.Visible = false;
                }
            }

            if (BtcCryptocurrency.DepositEnabled && BtcCryptocurrency.DepositMinimum > 0)
            {
                AdditionalInfoPlaceHolder.Visible = true;
                AdditionalInfoLiteral.Text        = String.Format(U6012.WARNINGMINBTCDEPOSIT, CryptocurrencyMoney.Parse(BtcCryptocurrency.DepositMinimum.ToString(), CryptocurrencyType.BTC).ToString());
            }
        }

        SetRadioItemsValues(RadioFrom);
        SetRadioItemsValues(RadioTo);
        SetRadioItemsValues(BTCTo);

        RemoveDuplicatesFromList();

        foreach (ListItem item in BTCPointsFrom.Items)
        {
            item.Attributes.Add("data-content", "<img src='../Images/OneSite/TransferMoney/GoCoin.png' /> BTC");
        }

        if (!TitanFeatures.IsRofriqueWorkMines)
        {
            LangAdder.Add(BalanceButton, U5009.BALANCE);
        }
        else
        {
            LangAdder.Add(BalanceButton, "Cash Deposits");
        }

        LangAdder.Add(btnDepositBTC, U4200.DEPOSIT);
        LangAdder.Add(classicbtcDepositBTC, U4200.DEPOSIT);
    }
예제 #18
0
    public static void TryPlaceOrder(int OfferId, CryptocurrencyMoney CCAmount, String SellerDescription)
    {
        //Loading selected offer
        var SelectedOffer = new CryptocurrencyTradeOffer(OfferId);
        var OfferCreator  = new Member(SelectedOffer.CreatorId);

        //Checking Creator's Balance
        if (SelectedOffer.OfferKind == CryptocurrencyOfferType.Buy)
        {
            if (SelectedOffer.CreatorId != Member.CurrentId)
            {
                if (OfferCreator.GetCryptocurrencyBalance(CryptocurrencyType.BTC) < CCAmount)
                {
                    throw new MsgException(U6010.ORDER_CREATORNOBALANCE);
                }
            }
        }
        else
        {
            if (SelectedOffer.CreatorId == Member.CurrentId)
            {
                if (OfferCreator.GetCryptocurrencyBalance(CryptocurrencyType.BTC) < CCAmount)
                {
                    throw new MsgException(U6010.ORDER_YOUNOBALANCE);
                }
            }
        }

        //If everything is good, creating transaction
        CryptocurrencyTradeTransaction NewTransaction = new CryptocurrencyTradeTransaction()
        {
            OfferId           = OfferId,
            ClientId          = Member.CurrentId,
            ExecutionTime     = AppSettings.ServerTime,
            PaymentStatus     = CryptocurrencyTransactionStatus.AwaitingPayment,
            CCAmount          = CCAmount,
            SellerDescription = SellerDescription
        };

        //Freezing cryptocurrency for transaction time
        //Current user clicked sell
        if (SelectedOffer.OfferKind == CryptocurrencyOfferType.Buy)
        {
            Member.Current.SubtractFromCryptocurrencyBalance(CryptocurrencyType.BTC, CCAmount.ToDecimal(), "Cryptocurrency trade", BalanceLogType.CryptocurrencyTrade);
        }
        //Current user clicked buy
        else
        {
            OfferCreator.SubtractFromCryptocurrencyBalance(CryptocurrencyType.BTC, CCAmount.ToDecimal(), "Cryptocurrency trade", BalanceLogType.CryptocurrencyTrade);
        }

        //Descreasing existing offer CC amount left
        SelectedOffer.AmountLeft = SelectedOffer.AmountLeft - CCAmount;
        if (SelectedOffer.AmountLeft <= CryptocurrencyMoney.Zero)
        {
            SelectedOffer.Status = CryptocurrencyOfferStatus.Finished;
        }
        SelectedOffer.Save();

        //Saving transaction, ESCROW starts here
        NewTransaction.Save(true);
    }
예제 #19
0
    public static void CreateNewOffer(CryptocurrencyOfferType OfferType, int CreatorId, Money MinPrice, Money MaxPrice, Money MinOfferValue, Money MaxOfferValue, int EscrowTime, String Description, CryptocurrencyMoney CryptocurrencyAmount)
    {
        CryptocurrencyTradeOffer NewTradeOffer = new CryptocurrencyTradeOffer();

        NewTradeOffer.Status       = CryptocurrencyOfferStatus.Active;
        NewTradeOffer.DateAdded    = DateTime.Now;
        NewTradeOffer.DateFinished = DateTime.Now.AddDays(365);

        NewTradeOffer.OfferKind     = OfferType;
        NewTradeOffer.CreatorId     = CreatorId;
        NewTradeOffer.MinPrice      = MinPrice;
        NewTradeOffer.MaxPrice      = MaxPrice;
        NewTradeOffer.MinOfferValue = MinOfferValue;
        NewTradeOffer.MaxOfferValue = MaxOfferValue;
        NewTradeOffer.Description   = Description;
        NewTradeOffer.EscrowTime    = EscrowTime;
        NewTradeOffer.Amount        = CryptocurrencyAmount;
        NewTradeOffer.AmountLeft    = CryptocurrencyAmount;

        NewTradeOffer.Save(true);
    }
예제 #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region TabAimer
        int SelectedTab = (Request.Params["SelectedTab"] != null) ? Int32.Parse(Request.Params["SelectedTab"]) : -1;
        if (SelectedTab >= 0)
        {
            MenuMultiView.ActiveViewIndex = SelectedTab;
            int Counter = MenuButtonPlaceHolder.Controls.Count - 1;
            foreach (Button b in MenuButtonPlaceHolder.Controls)
            {
                if (Counter == SelectedTab)
                {
                    b.CssClass = "ViewSelected";
                }
                else
                {
                    b.CssClass = "";
                }
                Counter--;
            }
        }
        #endregion

        #region OpenOfferDetails
        if ((!IsPostBack) && Request.Params.Get("oid") != null)
        {
            try
            {
                MenuMultiView.ActiveViewIndex = 4;

                CryptocurrencyAmount = String.Empty;
                int ProductId = Convert.ToInt32(Request.Params.Get("oid"));

                CryptocurrencyTradeOffer SelectedOffer = new CryptocurrencyTradeOffer(ProductId);

                var OfferCreator        = new Member(SelectedOffer.CreatorId);
                var OfferCreatorBalance = OfferCreator.GetCryptocurrencyBalance(CryptocurrencyType.BTC);

                //If creator of offer don't have enaugh currency in balance
                if (OfferCreatorBalance < SelectedOffer.AmountLeft)
                {
                    //If Offer AmountLeft is bigger than creator's balance, set max limit of buy to creator's balacne value
                    SelectedOffer.AmountLeft = OfferCreatorBalance;

                    if (OfferCreatorBalance == CryptocurrencyMoney.Zero)
                    {
                        SelectedOffer.Status = CryptocurrencyOfferStatus.Paused;
                        SelectedOffer.Save();
                        throw new MsgException(U6010.NOCREATORBALANCETOBUYOFFER);
                    }
                    SelectedOffer.Save();
                }

                SelectedOfferId = SelectedOffer.Id;

                decimal CountedMinCurrency, CountedMaxCurrency;

                CountedMinCurrency = decimal.Parse((SelectedOffer.MinOfferValue / SelectedOffer.MinPrice).ToClearString());
                CountedMaxCurrency = decimal.Parse((SelectedOffer.MaxOfferValue / SelectedOffer.MinPrice).ToClearString());
                if (SelectedOffer.AmountLeft < CryptocurrencyMoney.Parse(CountedMaxCurrency.ToString()))
                {
                    CountedMaxCurrency = decimal.Parse(SelectedOffer.AmountLeft.ToClearString());
                }


                Member User = new Member(SelectedOffer.CreatorId);
                CreatorNameLabel.Text = String.Format("<span style=\"float:left; margin-right: 10px\">{0}</span>{1}",
                                                      HtmlCreator.CreateAvatarPlusUsername(User),
                                                      CryptocurrencyPlatformManager.GetHtmlRatingStringForUser(User.Id));

                MinOfferLabel.Text = SelectedOffer.MinOfferValue.ToString();
                MaxOfferLabel.Text = SelectedOffer.MaxOfferValue.ToString();
                CurrencyAvailableToBuyLabel.Text = SelectedOffer.AmountLeft.ToString();

                MinCryptocurrencyAmount = CountedMinCurrency;
                MaxCryptocurrencyAmount = CountedMaxCurrency;
                MinCurrencyLabel.Text   = CryptocurrencyMoney.Parse(CountedMinCurrency.ToString()).ToString();
                MaxCurrencyLabel.Text   = CryptocurrencyMoney.Parse(CountedMaxCurrency.ToString()).ToString();


                PricePerCurrencyLabel.Text = SelectedOffer.MinPrice.ToString();
                PricePerCryptocurrency     = decimal.Parse(SelectedOffer.MinPrice.ToClearString());

                AmountToBuyTextBox.Text = CountedMinCurrency.ToString();

                //Updating Total Price label after every change of Cryptocurrency Amount
                AmountToBuyTextBox.Attributes.Add("onkeyup", "updatePrice();");

                CashToPayLabel.Text = decimal.Round(PricePerCryptocurrency * MinCryptocurrencyAmount, CoreSettings.GetMaxDecimalPlaces()).ToString();

                testerTB.Text       = SelectedOffer.Description;
                Description         = SelectedOffer.Description;
                BuyOfferButton.Text = L1.BUY;
            }
            catch (MsgException ex)
            {
                AllOffersErrorPanel.Visible = true;
                AllOffersErrorLiteral.Text  = ex.Message;
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex.Message);
                throw ex;
            }
        }
        #endregion

        #region OpenAddCommentView
        if ((!IsPostBack) && Request.Params.Get("foid") != null)
        {
            MenuMultiView.ActiveViewIndex = 5;
        }
        #endregion

        if (!IsPostBack)
        {
            AddLang();
        }

        //Constraint DataBind for second ManageTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 2)
        {
            ManageTabDataBind();
        }

        //Constraint DataBind for second HistoryTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 3)
        {
            OfferHistoryGridView.DataBind();
        }
    }
예제 #21
0
    protected void SetupSpecialTransfersProperties()
    {
        AdditionalInformationLiteralPlaceHolder.Visible = false;
        RequestedBTCCryptocurrencyTransfer = false;
        CurrencyTransferSignLiteral.Text   = AppSettings.Site.MulticurrencySign;
        TransferFromTextBox.Text           = "100.00";

        if (RadioFrom.SelectedValue == "Main balance" && RadioTo.SelectedValue == TokenCryptocurrency.Code + " Wallet")
        {
            AdditionalInformationLiteralPlaceHolder.Visible = true;
            AdditionalInformationLiteral.Text = string.Format("1 {0} = <b>{1}</b>",
                                                              TokenCryptocurrency.Code, TokenCryptocurrency.GetValue().ToString());

            if (TitanFeatures.IsTrafficThunder)
            {
                AdditionalInformationLiteral.Text = string.Format("1 {0} = <b>${1}</b>",
                                                                  TokenCryptocurrency.Code, TokenCryptocurrency.GetValue().ToShortClearString());
            }
        }

        if (RadioTo.SelectedValue == "BTC Wallet" || RadioTo.SelectedValue == "BTC" ||
            RadioFrom.SelectedValue == "CoinPayments" || RadioFrom.SelectedValue == "CoinBase" || RadioFrom.SelectedValue == "Blocktrail")
        {
            AdditionalInformationLiteralPlaceHolder.Visible = true;
            AdditionalInformationLiteral.Text = string.Format("1 BTC = <b>{0}</b>", CryptocurrencyFactory.Get(CryptocurrencyType.BTC).GetValue().ToString());

            if (BtcCryptocurrency.DepositEnabled && BtcCryptocurrency.DepositMinimum > 0)
            {
                AdditionalInformationLiteral.Text += "<br /><br />" + String.Format(U6012.WARNINGMINBTCDEPOSIT, CryptocurrencyMoney.Parse(BtcCryptocurrency.DepositMinimum.ToString(), CryptocurrencyType.BTC).ToString());
            }

            if (RadioFrom.SelectedValue == "CoinPayments")
            {
                AdditionalInformationLiteral.Text += " " + U6012.BTCDEPOSITLIMITINFO;
            }
        }

        if (RadioTo.SelectedValue == "BTC Wallet")
        {
            RequestedBTCCryptocurrencyTransfer = true;
            CurrencyTransferSignLiteral.Text   = "฿";
            TransferFromTextBox.Text           = "0.1";
        }
    }
예제 #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CryptocurrencyAmount = String.Empty;

        #region TabAimer
        int SelectedTab = (Request.Params["SelectedTab"] != null) ? Int32.Parse(Request.Params["SelectedTab"]) : -1;
        if (SelectedTab >= 0)
        {
            MenuMultiView.ActiveViewIndex = SelectedTab;
            int Counter = MenuButtonPlaceHolder.Controls.Count - 1;
            foreach (Button b in MenuButtonPlaceHolder.Controls)
            {
                if (Counter == SelectedTab)
                {
                    b.CssClass = "ViewSelected";
                }
                else
                {
                    b.CssClass = "";
                }
                Counter--;
            }
        }
        #endregion

        #region OpenDetailsInfoView
        if ((!IsPostBack) && Request.Params.Get("oid") != null)
        {
            int ProductId = Convert.ToInt32(Request.Params.Get("oid"));

            CryptocurrencyTradeOffer SelectedOffer = new CryptocurrencyTradeOffer(ProductId);
            MenuMultiView.ActiveViewIndex = 4;
            SelectedOfferId = SelectedOffer.Id;

            //Counting min-max currency amount limits to sell
            CryptocurrencyMoney CountedMinCurrency, CountedMaxCurrency;
            CountedMinCurrency = CryptocurrencyMoney.Parse((SelectedOffer.MinOfferValue / SelectedOffer.MaxPrice).ToClearString(), CryptocurrencyType.BTC);
            CountedMaxCurrency = CryptocurrencyMoney.Parse((SelectedOffer.MaxOfferValue / SelectedOffer.MaxPrice).ToClearString(), CryptocurrencyType.BTC);

            if (SelectedOffer.AmountLeft < CountedMaxCurrency)
            {
                CountedMaxCurrency = SelectedOffer.AmountLeft;
            }

            //Creator info
            Member User = new Member(SelectedOffer.CreatorId);
            CreatorNameLabel.Text = String.Format("<span style=\"float:left; margin-right: 10px\">{0}</span>{1}",
                                                  HtmlCreator.CreateAvatarPlusUsername(User),
                                                  CryptocurrencyPlatformManager.GetHtmlRatingStringForUser(User.Id));

            //Other info
            MinOfferLabel.Text = SelectedOffer.MinOfferValue.ToString();
            MaxOfferLabel.Text = SelectedOffer.MaxOfferValue.ToString();
            CurrencyAvailableToBuyLabel.Text = SelectedOffer.AmountLeft.ToString();

            MinCurrencyLabel.Text   = CountedMinCurrency.ToString();
            MaxCurrencyLabel.Text   = CountedMaxCurrency.ToString();
            MinCryptocurrencyAmount = decimal.Parse(CountedMinCurrency.ToClearString());
            MaxCryptocurrencyAmount = decimal.Parse(CountedMaxCurrency.ToClearString());

            PricePerCurrencyLabel.Text = SelectedOffer.MaxPrice.ToClearString();
            PricePerCryptocurrency     = decimal.Parse(SelectedOffer.MaxPrice.ToClearString());

            AmountToSellTextBox.Text = CountedMinCurrency.ToClearString();

            InfoForBuyerForOnClickSellTextBox.Text = String.Empty;
            Description = SelectedOffer.Description;

            //Updating Total Price label after every change of Cryptocurrency Amount
            AmountToSellTextBox.Attributes.Add("onkeyup", "updatePrice();");

            CashToPayLabel.Text = String.Format("{0}", decimal.Round(PricePerCryptocurrency * MinCryptocurrencyAmount, CoreSettings.GetMaxDecimalPlaces()).ToString());
        }
        #endregion

        #region OpenAddCommentView
        if ((!IsPostBack) && Request.Params.Get("foid") != null)
        {
            MenuMultiView.ActiveViewIndex = 5;
        }
        #endregion

        if (!IsPostBack)
        {
            AddLang();
        }

        //Constraint DataBind for second ManageTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 2)
        {
            ManageTabDataBind();
        }

        //Constraint DataBind for second HistoryTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 3)
        {
            OfferHistoryGridView.DataBind();
        }
    }
예제 #23
0
        public string TryMakeWithdrawal(int userId, string address, decimal amount, WithdrawalSourceBalance withdrawalSource)
        {
            var successMessage = U6000.REQUESTSENTPLEASEWAIT;
            var user           = new Member(userId);

            Money   amountInMoney;
            Money   amountInCorrectType;
            decimal amountInCryptocurrency;
            CryptocurrencyWithdrawRequest request = null;

            if (withdrawalSource == WithdrawalSourceBalance.MainBalance)
            {
                amountInCorrectType    = new Money(amount);
                amountInMoney          = new Money(amount);
                amountInCryptocurrency = ConvertFromMoney(amountInCorrectType);
            }
            else //Wallets
            {
                amountInCorrectType    = new CryptocurrencyMoney(CryptocurrencyType, amount);
                amountInMoney          = ConvertToMoney(amount);
                amountInCryptocurrency = amount;
            }

            //Full Validation
            ValidateWithdrawal(user, address, amount, withdrawalSource);

            var amountAfterFee = amountInCorrectType - EstimatedWithdrawalFee(amountInCryptocurrency, address, userId, withdrawalSource);

            if (amountAfterFee <= Money.Zero)
            {
                throw new MsgException("You can't withdraw a negative value.");
            }

            if (!IsAutomaticWithdrawal(user, amountInMoney))
            {
                CryptocurrencyWithdrawRequest.ValidatePendingRequests(userId, amountInMoney, this);
            }

            user.CashoutsProceed++;

            if (withdrawalSource == WithdrawalSourceBalance.MainBalance)
            {
                user.MoneyCashout += amountAfterFee;
                user.SubtractFromMainBalance(amountInMoney, String.Format("Requested {0} withdrawal", Type));
                user.Save();

                request = new CryptocurrencyWithdrawRequest(userId, address, amountAfterFee, amountInMoney, Type, withdrawalSource);
            }
            else //Wallets
            {
                user.MoneyCashout += ConvertToMoney(amountAfterFee.ToDecimal());
                user.SubtractFromCryptocurrencyBalance(Type, amount, String.Format("Requested {0} withdrawal", Type));
                user.Save();

                request = new CryptocurrencyWithdrawRequest(userId, address, amountAfterFee, new Money(amount), Type, withdrawalSource);
            }

            request.Save();

            if (IsAutomaticWithdrawal(user, amountInMoney))
            {
                request.Accept();
                successMessage = U5003.BTCWITHDRAWSUCCESS.Replace("%n%", amount.ToString() + ".");
            }

            return(successMessage);
        }
예제 #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        TokenCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.ERC20Token);
        BtcCryptocurrency   = CryptocurrencyFactory.Get(CryptocurrencyType.BTC);

        CommissionBalanceContainer.Visible  = AppSettings.Payments.CommissionBalanceEnabled;
        PointsBalanceContainer.Visible      = AppSettings.Points.PointsEnabled;
        TrafficBalanceContainer.Visible     = AppSettings.TitanFeatures.EarnTrafficExchangeEnabled;
        CashBalanceContainer.Visible        = AppSettings.Payments.CashBalanceEnabled;
        InvestmentBalanceContainer.Visible  = AppSettings.InvestmentPlatform.InvestmentBalanceEnabled;
        MarketplaceBalanceContainer.Visible = AppSettings.Payments.MarketplaceBalanceEnabled;

        BTCWalletContainer.Visible          = BtcCryptocurrency.WalletEnabled;
        ERC20TokenWalletContainer.Visible   = TokenCryptocurrency.WalletEnabled;
        ERC20FreezedTokensContainer.Visible = TokenCryptocurrency.WalletEnabled && AppSettings.Ethereum.ERC20TokensFreezeSystemEnabled;

        #region Customizations
        if (TitanFeatures.IsAhmed && HttpContext.Current.Request.Url.AbsolutePath.Contains("user/default.aspx"))
        {
            DailyTaskPlaceHolder.Visible = true;
        }

        if (TitanFeatures.PurchaseBalanceDisabled)
        {
            AdBalancePlaceHolder.Visible = false;
        }

        if (BtcCryptocurrency.WalletEnabled || TokenCryptocurrency.WalletEnabled)
        {
            //placeholder for custom balance design
        }

        if (BtcCryptocurrency.WalletEnabled)
        {
            CryptocurrencyMoney BTCWallet = Member.CurrentInCache.GetCryptocurrencyBalance(CryptocurrencyType.BTC);
            Money BTCValue = CryptocurrencyFactory.Get(CryptocurrencyType.BTC).GetValue();
            EstimatedBTCWalletValueLiteral.Text    = ((Money)(BTCWallet * BTCValue)).ToString();
            EstimatedBTCWalletValueLiteral.Visible = true;
        }

        if (TokenCryptocurrency.WalletEnabled)
        {
            CryptocurrencyMoney ERC20Wallet = Member.CurrentInCache.GetCryptocurrencyBalance(CryptocurrencyType.ERC20Token);
            Money ERC20TokenValue           = AppSettings.Ethereum.ERC20TokenRate;
            EstimatedERC20WalletValueLiteral.Text = ((Money)ERC20Wallet * ERC20TokenValue).ToString();
        }

        if (TokenCryptocurrency.WalletEnabled && AppSettings.Ethereum.ERC20TokensFreezeSystemEnabled)
        {
            CryptocurrencyMoney ERC20FreezedTokens = Member.CurrentInCache.GetCryptocurrencyBalance(CryptocurrencyType.ERCFreezed);
            Money ERC20TokenValue = AppSettings.Ethereum.ERC20TokenRate;
            EstimatedERC20FreezedTokensValueLiteral.Text = ((Money)ERC20FreezedTokens * ERC20TokenValue).ToString();
        }

        if (AppSettings.Points.PointsEnabled)
        {
            EstimatedPointsValueLiteral.Text = new Money((decimal)Member.CurrentInCache.PointsBalance / (decimal)Points.GetPointsPer1d()).ToString();
        }

        #endregion
    }
예제 #25
0
 public DepositToWalletCryptocurrencyButtonGenerator(Member member, CryptocurrencyMoney amount)
 {
     Amount = amount;
     Member = member;
 }