private string GetPlaceOfferResponse(InternalExchangeOfferResponse response, bool isAsk) { string message = string.Empty; if (response.AmountTransferd != decimal.Zero) { string amountTransferd = InternalExchangeManager.RecognizeCurrencyAndReturnString(true, FormatDecimal(response.AmountTransferd)); string valueTransferd = InternalExchangeManager.RecognizeCurrencyAndReturnString(false, FormatDecimal(response.ValueTransferd)); if (isAsk) { message += String.Format(U6012.SOLDSTOCKS, amountTransferd, valueTransferd); } else { message += String.Format(U6012.BOUGHTSTOCKS, amountTransferd, valueTransferd); } message += "<br />"; } if (response.AmountPlaced != decimal.Zero) { string amountPlaced = InternalExchangeManager.RecognizeCurrencyAndReturnString(true, FormatDecimal(response.AmountPlaced)); string valuePlaced = InternalExchangeManager.RecognizeCurrencyAndReturnString(false, FormatDecimal(response.ValuePlaced)); message += String.Format(U6012.NEWEXCHANGEOFFER, amountPlaced, valuePlaced); } return(message); }
private static InternalExchangeOfferResponse ExecuteBidOfferQuery(int userId, decimal numberOfStock, decimal pricePerStock) { string query = QueryBidProcedureFormat; query = string.Format(query, userId, numberOfStock, pricePerStock); InternalExchangeOfferResponse response = TableHelper.GetListFromRawQuery <InternalExchangeOfferResponse>(query).FirstOrDefault(); return(response); }
private static InternalExchangeOfferResponse PlaceBidOffer(int userId, decimal numberOfStock, decimal pricePerStock) { decimal commission = AppSettings.InternalExchange.InternalExchangeBidCommissionPercent; Money transactionValue = new Money(numberOfStock * pricePerStock); Money transactionFee = GetOfferFee(numberOfStock, pricePerStock, false); Member user = new Member(userId); if (GetAvailableFunds(user) >= (transactionValue + transactionFee).ToDecimal()) { InternalExchangeOfferResponse response = ExecuteBidOfferQuery(userId, numberOfStock, pricePerStock); //if (GetBalanceCode(false) == AppSettings.Site.CurrencyCode) // PoolDistributionManager.AddProfit(ProfitSource.InternalExchangeFee, transactionFee); return(response); } else { throw new MsgException(L1.NOTENOUGHFUNDS); } }
protected void PlaceOrderButton_Click(object sender, EventArgs e) { HideMessagges(); if (Member.CurrentInCache.IsAnyBalanceIsNegative()) { ErrorMessagePanel.Visible = true; ErrorMessageLiteral.Text = U6013.YOUCANTPROCEED; } else { if (Page.IsValid) { try { bool isAsk = IsCurrentlyAsk(); decimal numberOfStockToBuy = Decimal.Parse(NumberOfStockTextBox.Text); decimal valueOfStock = Decimal.Parse(ValueOfStockTextBox.Text); decimal totalValue = Decimal.Parse(TotalValueTextBox.Text); if (valueOfStock < AppSettings.InternalExchange.ICOInternalExchangeMinimalStockPrice) { throw new MsgException("Value of stock lower than allowed."); } if (numberOfStockToBuy <= Decimal.Zero || valueOfStock <= Decimal.Zero || totalValue <= Decimal.Zero) { ErrorLogger.Log(String.Format("INTERNAL EXCHANGE | Unexpected error | User: {0}({1}) | Size({2}) | Price({3}) | Total({4}) | IsAsk({5})", Member.CurrentName, Member.CurrentId, numberOfStockToBuy, valueOfStock, totalValue, isAsk)); throw new MsgException("Unexpected error. Value less than or equals to 0."); } InternalExchangeOfferResponse response = InternalExchangeManager.TryPlaceOrder(Member.CurrentId, numberOfStockToBuy, valueOfStock, isAsk); if (response != null) { SuccessMessageLiteral.Text = GetPlaceOfferResponse(response, isAsk); SuccessMessagePanel.Visible = true; } else { ErrorMessagePanel.Visible = true; ErrorMessageLiteral.Text = L1.ERROR_INFO; } DataBind(); } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessageLiteral.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex.Message); throw ex; } } else { ErrorMessagePanel.Visible = true; ErrorMessageLiteral.Text = "Unexpected Error - page is not valid"; } } }