コード例 #1
0
        public async Task <bool> NewTransaction(PurchaseVM purchaseVm, string cpass, long userId)
        {
            var user = await _manager.Users.GetSingle(userId);

            if (user != null && user.Password == EncryptionManager.Encrypt(cpass))
            {
                using (var con = new SEDCControle(_manager))
                {
                    var result = await con.Purchase(purchaseVm);

                    if (result.State == "0")
                    {
                        List <Power> pws = new List <Power>();
                        foreach (var x in result.Items)
                        {
                            pws.Add(new Power
                            {
                                Tid = x.Id, amt = x.Amt, kwh = x.Kwh, price = x.Price
                            });
                        }

                        _manager.SEDCTransaction.Add(new SEDCTransaction
                        {
                            verifyCode   = result.VerifyCode,
                            meterNum     = result.MeterNum,
                            CreateDate   = DateTime.Now,
                            transID      = result.TransId,
                            AMT          = result.Amt,
                            UserId       = userId,
                            Powers       = pws,
                            VAT          = result.Vat,
                            arrearAMT    = result.ArrearAmt,
                            buyTimes     = result.BuyTimes,
                            vendQty      = result.VendQty,
                            vendAMT      = result.VendAmt,
                            transTime    = result.TransTime,
                            token        = result.Token,
                            tariffCode   = result.TariffCode,
                            supplyAMT    = result.SupplyAmt,
                            state        = result.State,
                            stampTax     = result.StampTax,
                            regCode      = result.RegCode,
                            refCode      = result.RefCode,
                            netAMT       = result.NetAmt,
                            invoice      = result.Invoice,
                            feeAMT       = result.FeeAmt,
                            customerName = result.CustomerName,
                            commAMT      = result.CommAmt,
                            code         = result.Code,
                            checkCode    = result.CheckCode,
                            calcQty      = result.CalcQty
                        });
                        return(await _manager.Complete());
                    }
                }
            }
            return(false);
        }
コード例 #2
0
        public async Task <bool> UpdateBalanceSheet()
        {
            SEDCControle controle = new SEDCControle(_manager);
            var          b        = await controle.Balance(new BalanceVM());

            _manager._context.BalanceSheets.Add(new BalanceSheet
            {
                Balance   = double.Parse(b.Balance),
                CheckDate = DateTime.Now,
                State     = int.Parse(b.State),
                Username  = b.Username
            });
            return(await _manager.Complete());
        }