Ejemplo n.º 1
0
 public static Ticket ToTicket(this TicketRead ticketAzure)
 {
     var ticket = new Ticket();
     ticket.Id = Guid.Parse(ticketAzure.RowKey);
     ticket.Attendee = ticketAzure.PartitionKey;
     ticket.AccessCode = ticketAzure.AccessCode;
     if (ticketAzure.TicketStatus == "Paid")
     {
         ticket.Status = TicketStatus.Paid;
     }
     if (ticketAzure.TicketStatus == "Pending")
     {
         ticket.Status = TicketStatus.Pending;
     }
     ticket.TotalPrice = ticketAzure.TotalPrice;
     ticket.ParentEvent = new Event()
     {
         Name = ticketAzure.ParentEventName,
         Description = ticketAzure.ParentEventDescription,
         EventDate = ticketAzure.ParentEventDate
     };
     return ticket;
 }
Ejemplo n.º 2
0
        public void AddTicket(Ticket ticket)
        {
            var ticketToAdd = ticket.ToTicketRead();
            TableOperation addOperation = TableOperation.InsertOrReplace(ticketToAdd);
            _tableTicktes.Execute(addOperation);

            _cache.InvalidateCache(GenerateMyTicketsKey(ticketToAdd.PartitionKey));
        }
Ejemplo n.º 3
0
        public void DeleteTicket(Ticket ticket)
        {
            string partitionKey = ticket.Attendee;
            string rowKey = ticket.Id.ToString();
            var ticketToDelete = new TicketRead() { PartitionKey = partitionKey, RowKey = rowKey, ETag = "*" };

            TableOperation deleteOperation = TableOperation.Delete(ticketToDelete);
            _tableTicktes.Execute(deleteOperation);

            // Invalidate cache
            _cache.InvalidateCache(GenerateMyTicketsKey(partitionKey));
        }
Ejemplo n.º 4
0
        public void ConfirmTicket(Ticket ticket)
        {
            string partitionKey = ticket.Attendee;
            string rowKey = ticket.Id.ToString();
            var ticketToUpdate = new DynamicTableEntity { PartitionKey = partitionKey, RowKey = rowKey, ETag = "*" };
            Dictionary<string, EntityProperty> newProperties = new Dictionary<string, EntityProperty>();
            newProperties.Add("TicketStatus", new EntityProperty("Paid"));
            TableOperation updateOperation = TableOperation.Merge(ticketToUpdate);
            _tableTicktes.Execute(updateOperation);

            _cache.InvalidateCache(GenerateMyTicketsKey(ticket.Attendee));
        }