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);
        }
示例#2
0
 public ReservationView()
 {
     //default values
     Date       = DateTime.Now;
     Times      = new List <TimeModel>();
     Tables     = new EditableList <TableModel>();
     Day        = new DayReservation();
     ReturnCode = new ReturnCode(ReturnCodeLevel.RELOAD, Resource.ReloadOK, null);
     IsPicked   = false;
 }