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; } }
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; } }