public void Loaded() { try { Occupancies = _occupanciesRepository.GetOccupancies(); Tables = _tablesRepository.GetTables(); foreach (Data.Occupancy occupancy in Occupancies) { if (occupancy.Table.Id == Table.Id && occupancy.EndTime == null) { CurrentOccupancy = occupancy; if (CurrentOccupancy.Sales != null) { UnpaidAmount = CalculateUnpaidAmount(); PaidAmount = CalculatePaidAmount(); TotalAmount = CalculateTotalAmount(); } break; } else { CurrentOccupancy = null; } } CalculateFutureReservations(Table); } catch (NullReferenceException) { UnpaidAmount = 0; PaidAmount = 0; TotalAmount = 0; } }
public void Loaded() { Tables = _tablesRepository.GetTables(); if (IsNewTable) { ManipulatedTable = new Business.Table(); ManipulatedTable.Capacity = 1; ManipulatedTable.IsOccupied = false; ManipulatedTable.Name = null; } }
/// <summary> /// Checks if there are available tables for a certain date, for a certain amount of people. /// </summary> private void CalculateAvailableTables() { try { Tables = _tableRepo.GetTables(); AllTables = _tableRepo.GetTables(); for (int i = 0; i < Tables.Count; i++) { if (Tables[i].Capacity < ManipulatedReservation.AmountPeople) { Tables.Remove(Tables[i]); i--; } } // only show tables that don't have a reservation on them at that time (or within 2 hours) foreach (Reservation savedReservation in Reservations) { if (ManipulatedReservation.ID != savedReservation.ID) { if ((savedReservation.StartTime - ManipulatedReservation.StartTime).TotalHours >= 2 || (savedReservation.StartTime - ManipulatedReservation.StartTime).TotalHours < -2) { // do nothing } else { Tables.Remove(savedReservation.Table); } } } } catch (Exception ex) { ErrorHandler.ThrowError(0, ex.Message); } }
public ActionResult <IEnumerable <TableReadDto> > GetAllTables() { var tables = _repository.GetTables(); return(Ok(_mapper.Map <IEnumerable <TableReadDto> >(tables))); }