Example #1
0
        public List <Hall> Halls(DateTime dateTime, string sportCentre, string sport)
        {
            if (dateTime == null || sportCentre == null || sport == null)
            {
                return(new List <Hall>());
            }
            int         sportCentreID = GetSportCentreId(sportCentre);
            List <Hall> halls         = Hall.Where((Hall hall) => sportCentreID.Equals(hall.SportCentreID) && hall.Sport.ToString().Equals(sport)).ToList();

            return(halls);
        }
Example #2
0
 public int GetHallID(int sportCentreID, string sport)
 {
     return(Hall.Where((Hall hall) => sportCentreID.Equals(hall.SportCentreID) && hall.Sport.ToString().Equals(sport)).First().HallID);
 }
Example #3
0
        public List <Reservation> MyReservations()
        {
            string sportCentre = UserController.selectedSportCentre_MyReservations;
            string sport       = UserController.selectedSport_myReservations;

            if (sportCentre != null && sportCentre.Equals("All sport centres"))
            {
                sportCentre = null;
            }
            if (sport != null && sport.Equals("All sports"))
            {
                sport = null;
            }
            List <Reservation> reservations = Reservations(LoginController.currentyLoggedPerson);

            if (sportCentre == null && sport == null)
            {
                return(reservations);
            }
            if (sportCentre == null && sport != null)
            {
                for (int i = 0; i < reservations.Count; i++)
                {
                    Hall h = Hall.Where((Hall hall) => hall.HallID.Equals(reservations[i].HallID)).First();
                    if (!h.Sport.ToString().Equals(sport))
                    {
                        reservations.Remove(reservations[i]);
                        i--;
                    }
                }
            }
            if (sportCentre != null && sport == null)
            {
                SportCentre SC = SportCentre.Where((SportCentre SportCentre) => SportCentre.Name.Equals(sportCentre)).First();
                for (int i = 0; i < reservations.Count; i++)
                {
                    Hall h = Hall.Where((Hall hall) => hall.HallID.Equals(reservations[i].HallID)).First();
                    if (!h.SportCentreID.Equals(SC.SportCentreID))
                    {
                        reservations.Remove(reservations[i]);
                        i--;
                    }
                }
            }
            else if (sportCentre != null && sport != null)
            {
                SportCentre sc = SportCentre.Where((SportCentre SportCentre) => SportCentre.Name.Equals(sportCentre)).First();
                for (int i = 0; i < reservations.Count; i++)
                {
                    Hall h = Hall.Where((Hall hall) => hall.HallID.Equals(reservations[i].HallID)).First();
                    if (!h.SportCentreID.Equals(sc.SportCentreID) || !h.Sport.ToString().Equals(sport))
                    {
                        reservations.Remove(reservations[i]);
                        i--;
                    }
                }
            }
            UserController.selectedSportCentre_MyReservations = null;
            UserController.selectedSport_myReservations       = null;
            return(reservations);
        }
Example #4
0
 public Hall GetHall(int hallID)
 {
     return(Hall.Find(hallID));
 }