public DAO.Ticket createTicket(DAO.Ticket ticket) { try { using (var context = new Node1Context()) { var ticketModel = new EntityNode1.Ticket() { AccountId = ticket.AccountId, CreateDate = ticket.CreateDate, CustomerName = ticket.CustomerName, Id = ticket.Id, ProblemDescription = ticket.ProblemDescription }; context.Ticket.Add(ticketModel); context.SaveChanges(); ticket.Id = ticketModel.Id; return(ticket); }; } catch (Exception e) { Console.WriteLine("Ticket not saved"); throw; } }
public Block(int index, string previousHash, DAO.Ticket ticket, string hash) { this.Index = index; this.PreviousHash = previousHash; this.Ticket = ticket; this.Hash = hash; }
public Block(string previousHash, DAO.Ticket ticket) { Index = 0; PreviousHash = previousHash; Ticket = ticket; Hash = CalculateHash(); }
public DAO.Ticket getTicket(int id) { try { using (var context = new Node1Context()) { var ticketModel = context.Ticket.Where(x => x.Id == id).FirstOrDefault(); var daoTicket = new DAO.Ticket(ticketModel.Id, ticketModel.CustomerName, ticketModel.AccountId.Value, ticketModel.CreateDate.Value, ticketModel.ProblemDescription); return(daoTicket); }; } catch (Exception e) { Console.WriteLine("Couldn't load ticket"); throw; } }
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; } }
//Updates the id of the user who entered the incident. public void UpdateTicketUser(Ticket newTicket) { UpdateDocument(collectionName, "ticket_id", newTicket.Id, "user_id", newTicket.ReportedByUser.id); }
public void UpdateTicket(Ticket newTicket) { UpdateDocument(collectionName, "ticket_id", newTicket.Id, "status", newTicket.GetStatus()); }
public void AddTicket(Ticket ticket) { CreateDocument(collectionName, CreateTicketDocument(ticket)); }