示例#1
0
        public async Task <ActionResult> PayNow(List <CMS_DepositTransactionsModel> model)
        {
            var     Customer = Session["UserC"] as UserSession;
            var     Payment  = facP.GetDetail(model.FirstOrDefault().PaymentMethodId);
            var     Config   = facC.GetList().Where(x => x.ValueType == (int)Commons.ConfigType.USD).FirstOrDefault();
            decimal?Coin     = 0;

            if (!string.IsNullOrEmpty(Payment.URLApi))
            {
                var Priceobj = new PriceObjects();
                Priceobj = await GetLastPrice(Payment.URLApi);

                if (Priceobj.last.HasValue)
                {
                    Coin = model[0].Price / Priceobj.last.Value;
                }
                else
                {
                    Coin = model[0].Price / Priceobj.lastPrice.Value;
                }
            }
            model.ForEach(x =>
            {
                x.PaymentMethodName = Payment.PaymentName;
                x.WalletMoney       = Payment.WalletMoney;
                x.ExchangeRate      = Config != null ? Config.Value : 0;
                x.PayCoin           = Coin == 0 ? x.PayCoin : Coin.Value;
                x.CustomerId        = Customer.UserId;
                x.CustomerName      = Customer.UserName;
                x.DepositNo         = CommonHelper.RandomDepositNo();
            });
            var msg    = "";
            var result = facT.CreateDepositTransaction(model, ref msg, null);
            var obj    = new
            {
                msg    = msg,
                status = result
            };

            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
        public CMS_PaymentMethodModels GetDetail(string Id)
        {
            var data = _factory.GetDetail(Id);

            return(data);
        }