public DayReservation GetReservationsForDate(IUnitOfWork unitOfWork, DateTime date, List <TableModel> tables, string userId)
        {
            if (DayIsCancelled(unitOfWork, date))
            {
                return(new DayReservation(true));
            }

            // get all reservations for date
            var dayReservationList = repository.GetAll <ReservationModel>(unitOfWork).Where(res => res.Date.Date == date.Date).ToList();
            //  var dayReservationList = rezervations as IList<ReservationModel> ?? rezervations.ToList();

            // get all picked tables by the user for date
            var pickedTableList = GetPickedForDateAndUser(unitOfWork, date, userId);

            var day = new DayReservation();

            foreach (var table in tables)
            {
                var tr = new TableReservation(table);
                foreach (var reservation in dayReservationList.Where(rese => rese.TableId == table.Id))
                {
                    tr.AddReservation(reservation);
                }

                foreach (var reservation in pickedTableList.Where(rese => rese.TableId == table.Id))
                {
                    tr.AddPicked(reservation);
                }


                day.Add(tr);
            }

            return(day);
        }
Exemple #2
0
 public void Add(TableReservation tr)
 {
     this.reservations.Add(tr.TableNumber, tr);
 }