Пример #1
0
        public RoomViewLayer GetRoomViewByRoom(int Room_ID)
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Room>          RoomQuery         = jonghor.Room;
            DbSet <Room_Reserved> RoomReservedQuery = jonghor.Room_Reserved;

            RoomViewLayer roomviewlayer = new RoomViewLayer();

            foreach (Room room in RoomQuery)
            {
                if (room.Room_ID == Room_ID)
                {
                    roomviewlayer.room = room;

                    foreach (Person p in jonghor.Person)
                    {
                        if (p.Room_ID == room.Room_ID)
                        {
                            roomviewlayer.Reserved_num += 1;
                        }
                    }

                    foreach (Room_Reserved roomreserved in RoomReservedQuery)
                    {
                        if (room.Room_ID == roomreserved.Room_ID)
                        {
                            roomviewlayer.Reserved_num += roomreserved.Count;
                        }
                    }
                }
            }

            return(roomviewlayer);
        }
Пример #2
0
        public List <RoomViewLayer> GetRoomViewByDorm(int Dorm_ID)
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Room>          RoomQuery         = jonghor.Room;
            DbSet <Room_Type>     RoomTypeQuery     = jonghor.Room_Type;
            DbSet <Room_Reserved> RoomReservedQuery = jonghor.Room_Reserved;

            List <RoomViewLayer> Roomview = new List <RoomViewLayer>();

            foreach (Room room in RoomQuery)
            {
                RoomViewLayer roomviewlayer = new RoomViewLayer();
                if (room.Dorm_ID == Dorm_ID)
                {
                    roomviewlayer.room = room;

                    foreach (Person p in jonghor.Person)
                    {
                        if (p.Room_ID == room.Room_ID)
                        {
                            roomviewlayer.Reserved_num += 1;
                        }
                    }


                    foreach (Room_Reserved roomreserved in RoomReservedQuery)
                    {
                        if (room.Room_ID == roomreserved.Room_ID)
                        {
                            roomviewlayer.Reserved_num += roomreserved.Count;
                        }
                    }

                    if (Reserved_num < roomviewlayer.room.Room_Type.Max)
                    {
                        filter = roomviewlayer.room.Status;
                        Roomview.Add(roomviewlayer);
                    }
                }
            }

            return(Roomview);
        }