public static TicketRead ToTicketRead(this Ticket ticket) { var azureTicket = new TicketRead(); azureTicket.RowKey = ticket.Id.ToString(); azureTicket.PartitionKey = ticket.Attendee; azureTicket.RowKey = ticket.Id.ToString(); azureTicket.AccessCode = ticket.AccessCode; azureTicket.ParentEventName = ticket.ParentEvent.Name; azureTicket.ParentEventDescription = ticket.ParentEvent.Description; azureTicket.ParentEventDate = ticket.ParentEvent.EventDate; azureTicket.TicketStatus = ticket.Status.ToString(); azureTicket.TotalPrice = ticket.TotalPrice; return(azureTicket); }
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); }