Example #1
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            var preReservation = new PreReservationViewModel
            {
                FromWhatTime    = TimeSpan.Parse(ComboBoxGodzinaOdPreRezerwacji.Text),
                ToWhatTime      = TimeSpan.Parse(ComboBoxGodzinaDoPreRezerwacji.Text),
                HowManyPeoples  = int.Parse(TextBoxPreReservationIloscOsob.Text),
                ReservationDate = DatePickerDataPreRezerwacji.SelectedDate.Value
            };

            try
            {
                if (_serviceReservationOperation.CheckPreReservation(preReservation))
                {
                    _outputCalendar.MessageForAvailableTable(ComunicationLabel);
                }
                else
                {
                    _outputCalendar.MessageForNpotaAvailableTable(ComunicationLabel);
                }
            }
            catch (Exception)
            {
                _outputCalendar.MessageForErrorDuringReserwation(ComunicationLabel);
            }
        }
Example #2
0
        public RequestAvaibility Check(PreReservationViewModel preReservation)
        {
            var result     = new RequestAvaibility();
            var freeTables = GetAvailable(preReservation);

            AddTables(ref freeTables, preReservation.HowManyPeoples, ref result);
            return(result);
        }
Example #3
0
 private static bool CheckIfFree(this IEnumerable <Model.Models.Reservation> reservations,
                                 PreReservationViewModel preReservation)
 {
     if (reservations.Any())
     {
         var available = reservations.Where(r => r.ReservationDate == preReservation.ReservationDate &
                                            !(r.FromWhatTime >= preReservation.ToWhatTime ||
                                              r.ToWhatTime <= preReservation.FromWhatTime)).ToList();
         return(available.Count == 0);
     }
     return(true);
 }
        public void WhenCheckingPreReservation_ThenReturnTwotables(int howmanyPeoples)
        {
            var preReservation = new PreReservationViewModel
            {
                FromWhatTime    = new TimeSpan(12, 0, 0),
                ToWhatTime      = new TimeSpan(13, 30, 0),
                HowManyPeoples  = howmanyPeoples,
                ReservationDate = new DateTime(2018, 9, 19)
            };

            IServiceReservation service = new ReservationService();
            var check = service.GetAvailable(preReservation);
        }
        public void WhenCheckingPreReservation_ThenReturnFalse(int howmanyPeoples)
        {
            var preReservation = new PreReservationViewModel
            {
                FromWhatTime    = new TimeSpan(12, 0, 0),
                ToWhatTime      = new TimeSpan(13, 30, 0),
                HowManyPeoples  = howmanyPeoples,
                ReservationDate = new DateTime(2018, 9, 19)
            };

            IServiceReservation service = new ReservationService();
            var check = service.CheckPreReservation(preReservation);

            Assert.IsFalse(check);
        }
Example #6
0
 public bool CheckPreReservation(PreReservationViewModel preReservation)
 {
     return(Check(preReservation).IsAvailable);
 }
Example #7
0
        public List <Table> GetAvailable(PreReservationViewModel preReservation)
        {
            var tables = _tableRepository.TablesEager().GetFree(preReservation);

            return(tables);
        }
Example #8
0
 public static List <Table> GetFree(this List <Table> tables, PreReservationViewModel preReservation)
 {
     return(tables.Where(t => t.Reservation.CheckIfFree(preReservation)).ToList());
 }