Ejemplo n.º 1
0
        public async Task <TableReservationDto> CreateCurrentTableReservationAsync(CreateCurrentTableReservationDto dto)
        {
            Table table   = dto.Table.ToEntity();
            var   created = await _repository.CreateCurrentTableReservationAsync(table, dto.Hours);

            if (created == null)
            {
                throw new Exception("Table is not available.");
            }
            return(new TableReservationDto(created));
        }
 public async Task <ActionResult <TableReservationDto> > CreateCurrentTableReservation(CreateCurrentTableReservationDto dto)
 {
     if (dto == null)
     {
         return(BadRequest("Reservation data must be set!"));
     }
     try
     {
         return(Ok(await _service.CreateCurrentTableReservationAsync(dto)));
     }
     catch (Exception e)
     {
         return(Conflict(e.Message));
     }
 }