public async Task <List <TblReservationDTO> > Reservations() { try { var result = await _reservationRepo.GetReservations(); return(result); }catch (Exception ex) { throw new ArgumentException(ex.Message); } }
/// <summary> /// Sets Reservations and Tables. /// CalculateAvailableTables: <inheritdoc cref="CalculateAvailableTables"/> /// </summary> public void Loaded() { Reservations = _reservationRepo.GetReservations(); Tables = _tableRepo.GetTables(); if (IsNewReservation) { ManipulatedReservation = new Business.Reservation(); ManipulatedReservation.AmountPeople = 1; ManipulatedReservation.LastName = null; ManipulatedReservation.PhoneNumber = null; ManipulatedReservation.StartTime = DateTime.Now.AddHours(1); Time = DateTime.Now.AddHours(1).ToString(); SelectedTable = null; } CalculateAvailableTables(); }
/// <summary> /// Calculate and show the future reservations and reservations for today for a table. /// </summary> /// <param name="table">The table you want to see the reservations from.</param> private void CalculateFutureReservations(Data.Table table) { Reservations = _reservationsRepository.GetReservations(); FutureReservations.Clear(); foreach (Data.Reservation reservation in Reservations) { try { if (reservation.Table.Id == Table.Id) { if ((reservation.StartTime - DateTime.Now).TotalHours < 48 && (reservation.StartTime - DateTime.Now).TotalHours > -2) { FutureReservations.Add(reservation); } } } catch (NullReferenceException) { // do nothing, this reservation doesnt have a table } } }
public ActionResult <IEnumerable <ReservationReadDto> > GetAllReservations() { var reservations = _repository.GetReservations(); return(Ok(_mapper.Map <IEnumerable <ReservationReadDto> >(reservations))); }