Ejemplo n.º 1
0
        public async Task HandleReceiptFor(GarageTicket ticket, string emailAddress, ReceiptFormat receiptFormat)
        {
            if (ticket.Payment is ParkingPermit permit)
            {
                // Simplistic approach: parking permit does not generate receipt
                return;
            }

            var receiptContent = _contentBuilder.BuildContent(ticket);

            switch (receiptFormat)
            {
            case ReceiptFormat.Email:

                await _emailClient.EmailAsync(emailAddress, receiptContent);

                break;

            case ReceiptFormat.Print:

                await _deviceClient.PrintAsync(receiptContent);

                break;
            }
        }
        public string BuildContent(GarageTicket ticket)
        {
            var receiptContent = $"Check in time: {ticket.CheckInTime}\n" +
                                 $"Check out time: {ticket.CheckOutTime}\n" +
                                 $"Total charge: ${ticket.AmountCharged}";

            return(receiptContent);
        }
Ejemplo n.º 3
0
 public Task SaveAsync(GarageTicket ticket)
 {
     if (!_storage.Any(t => t.TicketId == ticket.TicketId))
     {
         _storage.Add(new GarageTicket
         {
             TicketId    = ticket.TicketId,
             CheckInTime = ticket.CheckInTime,
             Payment     = ticket.Payment
         });
     }
     return(Task.FromResult(0));
 }
 protected abstract Task <bool> CheckOutAsync(T payment, GarageTicket ticket);
 public async Task <bool> CheckOutAsync(GarageTicket ticket) =>
 await CheckOutAsync((T)ticket.Payment, ticket);