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