Esempio n. 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);
Esempio n. 3
0
 public Ticket GetWithId(TicketId ticketId) => Tickets.First(t => t.Id == ticketId);
Esempio n. 4
0
 public QueuedTickets RemoveWithId(TicketId ticketId)
 {
     return(new QueuedTickets(new List <Ticket>(Tickets
                                                .Where(t => t.Id != ticketId))));
 }
Esempio n. 5
0
 private Result Validate(TicketId ticketId) => Tickets.ContainsEntityWith(ticketId).OnBoth(
     () => Fail <Ticket>($"{nameof(Ticket)} with Id {ticketId} already exist."),
     Ok);
Esempio n. 6
0
 public Result CanAddFrom(TicketId ticketId, int ticketNumber) =>
 Validate(ticketId)
 .OnSuccess(() => Validate(ticketNumber));