Exemple #1
0
 public QueuedTickets AddFrom(
     TicketId ticketId,
     int ticketNumber,
     DateTime ticketPrintingTimestamp) => new QueuedTickets(new List <Ticket>(Tickets)
 {
     new Ticket(ticketId, ticketNumber, ticketPrintingTimestamp)
 });
 public Result <CustomerQueue> AddTicket(
     TicketId ticketId,
     int ticketNumber) =>
 QueuedTickets.CanAddFrom(ticketId, ticketNumber)
 .OnSuccess(() => ApplyChange(new TicketAdded(Id, ticketId, ticketNumber)))
 .OnSuccess(_ => AvailableCounters.MapFirstFree(counter => ApplyChange(new CustomerTaken(Id, counter.Id, ticketId))))
 .ToTypedResult(this);
Exemple #3
0
 public Ticket GetWithId(TicketId ticketId) => Tickets.First(t => t.Id == ticketId);
Exemple #4
0
 public QueuedTickets RemoveWithId(TicketId ticketId)
 {
     return(new QueuedTickets(new List <Ticket>(Tickets
                                                .Where(t => t.Id != ticketId))));
 }
Exemple #5
0
 private Result Validate(TicketId ticketId) => Tickets.ContainsEntityWith(ticketId).OnBoth(
     () => Fail <Ticket>($"{nameof(Ticket)} with Id {ticketId} already exist."),
     Ok);
Exemple #6
0
 public Result CanAddFrom(TicketId ticketId, int ticketNumber) =>
 Validate(ticketId)
 .OnSuccess(() => Validate(ticketNumber));