public async Task <IActionResult> DeployContract(DeployContractVM contractVM)
        {
            try
            {
                ContractParam  contractParam   = new ContractParam(contractVM);
                ContractAccess contractAccess  = new ContractAccess((int)contractVM.Network);
                var            transactionHash = await contractAccess.DeployContract(contractParam);


                Escrow newContract = new Escrow(transactionHash.ToString(), contractVM);

                using (var _context = new ApplicationDbContext())
                {
                    _context.DeployedContracts.Add(newContract);

                    await _context.SaveChangesAsync();

                    //contractVM.ContractList = await _context.DeployedContracts.Include(p => p.Receipt).ToListAsync();
                }
                Log.Information("Contract Deployed at network: " + contractVM.Network.ToString() + ", TxHash: " + transactionHash);
                return(new JsonResult(transactionHash));
            }
            catch (Exception e)
            {
                return(new JsonResult(e.Message));
            }
        }
        public ContractResult Create(ContractParam param)
        {
            Data.Entity.Contract entity = ContractParamConverter.Convert(param, null);
            ContractDao.Save(entity);

            return(ContractResultConverter.Convert(entity));
        }
        public async Task <IActionResult> ShowEstimatedGasPrice(DeployContractVM contractVM)
        {
            ContractAccess contractAccess = new ContractAccess((int)contractVM.Network);
            ContractParam  param          = new ContractParam(contractVM);
            var            gasPrice       = await contractAccess.GetGasLimit(param);

            return(new JsonResult(gasPrice));
        }
Beispiel #4
0
        public ApiResponse Create(ContractParam param)
        {
            ContractProcessor = new ContractProcessor();
            Response          = new ApiResponse();

            try
            {
                Response.text   = JsonConverter.JsonConverter.ObjToJson(ContractProcessor.Create(param));
                Response.result = true;

                return(Response);
            }

            catch
            {
                Response.text   = "Something went wrong :(";
                Response.result = false;

                return(Response);
            }
        }
Beispiel #5
0
        public ApiResponse Update(long id, ContractParam param)
        {
            ContractProcessor = new ContractProcessor();
            Response          = new ApiResponse();

            try
            {
                ContractProcessor.Update(id, param);
                Response.text   = "Entity was successfully updated";
                Response.result = true;

                return(Response);
            }
            catch
            {
                Response.text   = "Unfortunately something went wrong :(";
                Response.result = false;

                return(Response);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 支付中签约
        /// </summary>
        /// <param name="Api"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static XElement ContractOrder(CreatePreOrder entity)
        {
            ContractParam param = new ContractParam()
            {
                out_trade_no             = entity.OrderCode,
                device_info              = "A123",
                body                     = entity.OrderContent,
                notify_url               = entity.NotifyUrl,
                total_fee                = Convert.ToInt32(entity.OrderAmount * 100).ToString(),
                spbill_create_ip         = entity.Ip,
                trade_type               = "JSAPI",
                openid                   = entity.OpenId,
                plan_id                  = "12",
                contract_code            = "100001256",
                request_serial           = "100001253336",
                contract_display_account = "123",
                contract_notify_url      = entity.NotifyUrl,
                attach                   = entity.Attach
            };

            return(Post(Host.PayContract, param));
        }
 public void Update(long id, ContractParam param)
 {
     Data.Entity.Contract oldEntity = ContractDao.Find(id);
     Data.Entity.Contract newEntity = ContractParamConverter.Convert(param, null);
     ContractDao.Update(newEntity);
 }
Beispiel #8
0
 public void ValidateParameters(ContractParam param)
 {
     throw new NotImplementedException();
 }