public TicketPresentation PurchaseReservedTicket(string EventId, string ReservationId)
        {
            TicketPresentation ticket = new TicketPresentation();
            PurchaseTicketResponse response = new PurchaseTicketResponse();
            PurchaseTicketRequest request = new PurchaseTicketRequest();
            request.ReservationId = ReservationId;
            request.EventId = EventId;
            request.CorrelationId = ReservationId; // In this instance we can use the ReservationId

            response = _ticketService.PurchaseTicket(request);
            if (response.Success)
            {
                ticket.Description = String.Format("{0} ticket(s) purchased for {1}.<br/><small>Your e-ticket id is {2}.</small>", response.NoOfTickets, response.EventName, response.TicketId);
                ticket.EventId = response.EventId;
                ticket.TicketId = response.TicketId;
                ticket.WasAbleToPurchaseTicket = true;
            }
            else
            {
                ticket.WasAbleToPurchaseTicket = false;
                ticket.Description = response.Message;
            }

            return ticket;
        }
        public static PurchaseTicketResponse ConvertToPurchaseTicketResponse(this TicketPurchase ticketPurchase)
        {
            PurchaseTicketResponse response = new PurchaseTicketResponse();

            response.TicketId = ticketPurchase.Id.ToString();
            response.EventName = ticketPurchase.Event.Name;
            response.EventId = ticketPurchase.Event.Id.ToString();
            response.NoOfTickets = ticketPurchase.TicketQuantity;

            return response;
        }
        public PurchaseTicketResponse PurchaseTicket(PurchaseTicketRequest PurchaseTicketRequest)
        {
            PurchaseTicketResponse response = new PurchaseTicketResponse();

            try
            {
                // Check for a duplicate transaction using the Idempotent Pattern,
                // the Domain Logic could cope but we can't be sure.
                if (_reservationResponse.IsAUniqueRequest(PurchaseTicketRequest.CorrelationId))
                {
                    TicketPurchase ticket;
                    Event Event = _eventRepository.FindBy(new Guid(PurchaseTicketRequest.EventId));

                    if (Event.CanPurchaseTicketWith(new Guid(PurchaseTicketRequest.ReservationId)))
                    {
                        ticket = Event.PurchaseTicketWith(new Guid(PurchaseTicketRequest.ReservationId));

                        _eventRepository.Save(Event);

                        response = ticket.ConvertToPurchaseTicketResponse();
                        response.Success = true;
                    }
                    else
                    {
                        response.Message = Event.DetermineWhyATicketCannotbePurchasedWith(new Guid(PurchaseTicketRequest.ReservationId));
                        response.Success = false;
                    }

                    _reservationResponse.LogResponse(PurchaseTicketRequest.CorrelationId, response);
                }
                else
                {
                    // Retrieve last response
                    response = _reservationResponse.RetrievePreviousResponseFor(PurchaseTicketRequest.CorrelationId);
                }
            }
            catch (Exception ex)
            {
                // Shield Exceptions
                response.Message = ErrorLog.GenerateErrorRefMessageAndLog(ex);
                response.Success = false;
            }

            return response;
        }