public JsonResult SubmitOrder(SubmitOrderEntity order)
        {
            string msg = string.Empty;

            try
            {
                CrmMemberModel cdb1 = new CrmMemberModel();

                if (string.IsNullOrEmpty(order.SourceAccountId))
                {
                    order.SourceAccountId = Session["SourceAccountId"] as string;
                }
                //var currentUser = cdb1.getCrmMemberListInfoData(order.SourceAccountId).FirstOrDefault();
                //decimal dec = cdb1.GetPrepayAccount(currentUser.Uid).AccountMoney;
                if (!SubmitOrderDBModel.UpdateOrderInfo(order))
                {
                    msg = "提交订单失败,请检查网络连接。如频繁不能提交,请联系客服";
                }
            }
            catch (Exception ex)
            {
                msg = "提交订单失败,请检查网络连接。如频繁不能提交,请联系客服";
                Logger.Log(LoggingLevel.Normal, ex);
            }
            return(Json(msg));
        }
Example #2
0
        // SubmitOrder
        public async Task <SubmitOrder> SubmitOrder(string currency, TradingPair tradingPair, OrderType orderType, double amount, double price)
        {
            string market = String.Format("{0}_{1}", currency, tradingPair.ToString());

            using (var client = new HttpClient())
            {
                // create the URL string.
                string endpoint = "api/private/submitOrder";

                // JSON POST parameters
                JObject jObject = new JObject();
                jObject["Market"] = market;
                jObject["Type"]   = orderType.ToString();
                jObject["Amount"] = amount;
                jObject["Price"]  = price;
                string postParams = jObject.ToString(Formatting.None, null);

                // Http Client params
                SetHttpClientPropertiesPrivate(client, endpoint, postParams);

                // make the request
                var content  = new StringContent(postParams, Encoding.UTF8, "application/json");
                var response = await client.PostAsync(endpoint, content);

                // parse the response and return the data.
                var jsonResponseString = await response.Content.ReadAsStringAsync();

                SubmitOrderEntity submitOrderEntity = new SubmitOrderEntity();

                try
                {
                    submitOrderEntity = JsonConvert.DeserializeObject <SubmitOrderEntity>(jsonResponseString);
                }
                catch (Exception e)
                {
                    throw new Exception(_ParseError, e);
                }

                // Check success message from server
                if (submitOrderEntity.Success == false)
                {
                    throw new Exception(_SuccessError);
                }

                return(submitOrderEntity.Result);
            }
        }