Example #1
0
 public TransactionModel GetTransaction(string tx)
 {
     using (AltruismContext ctx = new AltruismContext())
     {
         return(ctx.Transactions.Find(tx));
     }
 }
Example #2
0
 public List <string> GetContributors()
 {
     using (AltruismContext ctx = new AltruismContext())
     {
         List <string> result = ctx.Contributors.Select(x => x.Address).ToList();
         return(result);
     }
 }
Example #3
0
 public TransactionModel GetLastTransaction()
 {
     using (AltruismContext ctx = new AltruismContext())
     {
         TransactionModel model = ctx.Transactions.OrderByDescending(x => x.timeStamp).FirstOrDefault();
         return(model);
     }
 }
Example #4
0
 public IEnumerable <TransactionModel> GetUnmanagedTransactions()
 {
     using (AltruismContext ctx = new AltruismContext())
     {
         IEnumerable <TransactionModel> result = ctx.Transactions.Where(x => !x.managed).OrderBy(x => x.timeStamp).ToList();
         if (result == null)
         {
             return(new List <TransactionModel>());
         }
         return(result);
     }
 }
Example #5
0
 public int GetLastBlock()
 {
     using (AltruismContext ctx = new AltruismContext())
     {
         PropertyModel model = ctx.Properties.Where(x => x.Name == "lastBlock").FirstOrDefault();
         if (model == null)
         {
             return(0);
         }
         int block;
         int.TryParse(model.Value, out block);
         return(block);
     }
 }
Example #6
0
 public bool AddTransaction(TransactionModel tx)
 {
     using (AltruismContext ctx = new AltruismContext())
     {
         TransactionModel modelExists = ctx.Transactions.Find(tx.hash);
         if (modelExists != null)
         {
             return(false);
         }
         ctx.Transactions.Add(tx);
         ctx.SaveChanges();
     }
     return(true);
 }
Example #7
0
 public bool AddContributor(string address)
 {
     using (AltruismContext ctx = new AltruismContext())
     {
         ContributorModel modelExists = ctx.Contributors.Find(address);
         if (modelExists != null)
         {
             return(false);
         }
         modelExists         = new ContributorModel();
         modelExists.Address = address;
         ctx.Contributors.Add(modelExists);
         ctx.SaveChanges();
     }
     return(true);
 }
Example #8
0
 public bool SetManaged(string tx, bool isAltruist, bool isHacked, string altruistTx = null)
 {
     using (AltruismContext ctx = new AltruismContext())
     {
         TransactionModel model = ctx.Transactions.Find(tx);
         if (model != null)
         {
             model.altruismMode = isAltruist;
             model.hackedMode   = isHacked;
             model.managed      = true;
             model.altruistTx   = altruistTx;
             ctx.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Example #9
0
 public bool UpdateProperty(string name, string value)
 {
     using (AltruismContext ctx = new AltruismContext())
     {
         PropertyModel model = ctx.Properties.Where(x => x.Name == name).FirstOrDefault();
         if (model == null)
         {
             model       = new PropertyModel();
             model.Name  = name;
             model.Value = value;
             ctx.Properties.Add(model);
         }
         else
         {
             model.Value = value;
         }
         ctx.SaveChanges();
     }
     return(true);
 }