public async Task <NewTicketSummary> NewAsync(ITicketCreation ticket) { var currProjection = await projectionsRepo.GetProjectionByIdAsync(ticket.ProjectionId); if (currProjection.StartDate <= DateTime.Now) { var constraintMessage = "It is too late to buy tickets for this projection! Seats are no longer available."; return(new NewTicketSummary(false, constraintMessage)); } else { return(await newTicket.NewAsync(ticket)); } }
public async Task <NewTicketSummary> NewAsync(ITicketCreation ticket) { var existinglReservation = await reservationRepo .GetAsync(ticket.ProjectionId, ticket.Row, ticket.Column); var existingTicket = await ticketRepo.GetAsync(ticket.ProjectionId, ticket.Row, ticket.Column); if (existinglReservation != null || existingTicket != null) { var constraintMessage = "This seat is not available! You can not buy ticket for it"; return(new NewTicketSummary(false, constraintMessage)); } else { return(await newTicket.NewAsync(ticket)); } }
public async Task <IHttpActionResult> WithoutReservation(TicketCreationModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await cancelReservations.CancelExpiredReservationsAsync(DateTime.Now); NewTicketSummary summary = await newTicket.NewAsync(new Ticket(model.ProjectionId, model.Row, model.Column)); if (summary.IsCreated) { return(Ok(summary.TicketOutputReceipt)); } else { return(BadRequest(summary.Message)); } }