示例#1
0
        public async Task <TableReservationDto> CreateTableReservationAsync(CreateTableReservationDto dto)
        {
            TableReservation created = await _repository
                                       .CreateTableReservationAsync(dto.NumberOfSeats, dto.Date.AddHours(1), dto.Hours, dto.Name);

            if (created == null)
            {
                throw new Exception("No available tables.");
            }
            return(new TableReservationDto(created));
        }
 public async Task <ActionResult <TableReservationDto> > CreateTableReservation([FromBody] CreateTableReservationDto tableReservationDto)
 {
     if (tableReservationDto == null)
     {
         return(BadRequest("Reservation data must be set!"));
     }
     try
     {
         return(Ok(await _service.CreateTableReservationAsync(tableReservationDto)));
     }
     catch (Exception e)
     {
         return(Conflict(e.Message));
     }
 }