Exemple #1
0
        public void SaveContract(string name, string cpp, string abi = null, string hpp = null)
        {
            Contract contract;
            var      isCreate = false;

            if (_ef.Contracts.Any(x => x.Name == name))
            {
                isCreate = false;
                contract = _ef.Contracts.Single(x => x.Name == name);
            }
            else
            {
                isCreate      = true;
                contract      = new Contract();
                contract.Name = name;
            }

            contract.Cpp          = cpp;
            contract.Hpp          = hpp;
            contract.Abi          = abi;
            contract.DeployedTime = DateTime.Now;
            contract.Status       = ContractStatus.Updating;
            if (isCreate)
            {
                _ef.Add(contract);
            }
            _ef.SaveChanges();

            var contractFolder = ConcatPath(name);

            if (!Directory.Exists(contractFolder))
            {
                Directory.CreateDirectory(contractFolder);
            }

            File.WriteAllText(Path.Combine(contractFolder, name + ".cpp"), cpp);
            if (abi != null)
            {
                File.WriteAllText(Path.Combine(contractFolder, name + ".abi"), abi);
            }
            if (hpp != null)
            {
                File.WriteAllText(Path.Combine(contractFolder, name + ".hpp"), hpp);
            }
        }
 public void Add(Accommodation newAccommodation)
 {
     _context.Add(newAccommodation);
     _context.SaveChanges();
 }