コード例 #1
0
        public bool Validate(ITheatreLayout theatreLayout, ITicketRequest ticketRequest)
        {
            var totalSeatVacant = theatreLayout.Rows.Sum(row => row.TotalVacant);

            if (totalSeatVacant < ticketRequest.TicketCount)
            {
                throw new RuleValidationException(TheatreCannotHostParty);
            }
            return(true);
        }
コード例 #2
0
 public bool Validate(ITheatreLayout theatreLayout, ITicketRequest ticketRequest)
 {
     if (!theatreLayout.Rows.Any(
             row => row.Sections.Any(
                 section => section.SeatVacant >= ticketRequest.TicketCount)) &&
         theatreLayout.Rows.Sum(row => row.TotalVacant) > ticketRequest.TicketCount)
     {
         throw new RuleValidationException(PartyCannotSitInSingleRowFailure);
     }
     return(true);
 }