Esempio n. 1
0
        /// <summary>
        /// Filters booked class rooms by grouping the room id's in the booking table. If the room id has a count of 2, it is then removed from RoomList.
        /// If the count has 1 or 0, the Booking_Limit property is updated respectively.
        /// </summary>
        public void CheckBookingLimit()
        {
            foreach (var item in RoomReference.RoomList.ToList())
            {
                if (item.Booking_Limit != 0)
                {
                    RoomReference.RoomList.Remove(item);
                    RoomReference.RoomList.Add(item);
                }
                item.Booking_Limit = 0;
            }

            if (RoomReference.SelectedRoomtypeFilter == "Klasselokale" || RoomReference.SelectedRoomtypeFilter == "Alle")
            {
                var query = (from b in BookingCatalogSingleton.Instance.Bookings
                             where b.Date == RoomReference.Date.DateTime && b.Time_end >= RoomReference.TimeStart &&
                             b.Time_start <= RoomReference.TimeEnd
                             group b by b.Room_Id into RoomGroup
                             select new
                {
                    LimitKey = RoomGroup.Key,
                    Count = RoomGroup.Count(),
                }).ToList();

                foreach (var klasseLokaler in query)
                {
                    var query1 = (from r in RoomReference.RoomList
                                  where r.Room_Id.Equals(klasseLokaler.LimitKey)
                                  select r).ToList();
                    foreach (var variable in query1)
                    {
                        if (klasseLokaler.Count >= 2)
                        {
                            RoomReference.RoomList.Remove(variable);
                        }
                        if (klasseLokaler.Count == 1)
                        {
                            foreach (var item in RoomReference.RoomList.ToList())
                            {
                                if (variable.Room_Id == item.Room_Id)
                                {
                                    item.Booking_Limit = 1;
                                    RoomReference.RoomList.Remove(item);
                                    RoomReference.RoomList.Add(item);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Returns true if a teacher has booked 3 rooms or more.
        /// </summary>
        public bool ThreeRoomsBookingLimit()
        {
            var query = (from b in BookingCatalogSingleton.Instance.Bookings
                         where b.User_Id == LoginHandler.CurrentUserId &&
                         b.Date.Date == RoomReference.Date.Date &&
                         b.Time_end >= RoomReference.TimeStart && b.Time_start <= RoomReference.TimeEnd
                         group b by b.User_Id into RoomGroup
                         select new
            {
                LimitKey = RoomGroup.Key,
                Count = RoomGroup.Count()
            }).ToList();

            foreach (var item in query)
            {
                if (item.Count >= 3)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// A method making sure a teacher has no more than three booking on a inputted timeinterval
        /// </summary>
        /// <returns>Returns true if a teacher can book another room, and false if he has more than three booking</returns>
        public bool ThreeRoomsBookingLimit()
        {
            var query = (from b in AllBookingsViewCatalogSingleton.Instance.AllBookings
                         where b.User_Id == LoginHandler.CurrentUserId &&
                         b.Date.Date == TCPREF.BookingIsSelected.Date.Date &&
                         b.BookingEnd >= TCPREF.InputTimeStart && b.BookingStart <= TCPREF.InputTimeEnd
                         group b by b.User_Id
                         into RoomGroup
                         select new
            {
                LimitKey = RoomGroup.Key,
                Count = RoomGroup.Count()
            }).ToList();



            //var query = (from b in BookingCatalogSingleton.Instance.Bookings
            //             where b.User_Id == LoginHandler.CurrentUserId &&
            //                   b.Date.Date == TCPREF.BookingIsSelected.Date.Date
            //                  && b.Time_end >= TCPREF.InputTimeStart && b.Time_start <= TCPREF.InputTimeEnd
            //             group b by b.User_Id
            //    into RoomGroup
            //             select new
            //             {
            //                 LimitKey = RoomGroup.Key,
            //                 Count = RoomGroup.Count()
            //             }).ToList();

            foreach (var item in query)
            {
                if (item.Count >= 3)
                {
                    return(false);
                }
            }
            return(true);
        }