Example #1
0
 public Blockchain.Block getBlock(int id)
 {
     try
     {
         using (var context = new Node1Context())
         {
             var blockModel  = context.Block.Where(x => x.Id == id).FirstOrDefault();
             var ticketModel = getTicket(blockModel.IdTicket.Value);
             var daoTicket   = new DAO.Ticket(ticketModel.Id, ticketModel.CustomerName, ticketModel.AccountId, ticketModel.CreateDate, ticketModel.ProblemDescription);
             var block       = new Blockchain.Block(blockModel.Id, blockModel.PreviousHash, daoTicket, blockModel.Hash);
             return(block);
         };
     }
     catch (Exception e)
     {
         Console.WriteLine("Couldn't load ticket");
         throw;
     }
 }
Example #2
0
        public List <Blockchain.Block> getBlockChain()
        {
            try
            {
                var listaBlocks = GetBlocks();
                List <Blockchain.Block> BlockList = new List <Blockchain.Block>();
                foreach (EntityNode1.Block block in listaBlocks)
                {
                    var daoTicket            = getTicket(block.IdTicket.Value);
                    Blockchain.Block bcBlock = new Blockchain.Block()
                    {
                        Index = block.Id, Hash = block.Hash, PreviousHash = block.PreviousHash, Ticket = daoTicket
                    };
                    BlockList.Add(bcBlock);
                }

                return(BlockList);
            }
            catch (Exception e)
            {
                Console.WriteLine("Couldn't load chain");
                throw;
            }
        }