Пример #1
0
        public Person GetUser(string name)
        {
            JongHorDBEntities1 db   = new JongHorDBEntities1();
            Person             user = db.Person.Where(u => u.Username == name).First();

            return(user);
        }
Пример #2
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);
        }
Пример #3
0
        public List <Dorm_Picture> GetDorm_Picture()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Dorm_Picture> dormDal = jonghor.Dorm_Picture;

            return(dormDal.ToList <Dorm_Picture>());
        }
Пример #4
0
        public List <Person> GetPerson()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Person> dormDal = jonghor.Person;

            return(dormDal.ToList <Person>());
        }
Пример #5
0
        public IQueryable <Message> GetMessage(string name)
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            IQueryable <Message> messages = jonghor.Message.Where(m => m.Receiver_Username == name);

            return(messages);
        }
Пример #6
0
        public Dorm GetDorm(string name)
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            Dorm dorm = jonghor.Dorm.Where(d => d.Person.Username == name).First();

            return(dorm);
        }
Пример #7
0
        public List <Dorm> GetDorm()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Dorm> dormDal = jonghor.Dorm;

            return(dormDal.ToList <Dorm>());
        }
Пример #8
0
        public List <Dorm_Label> GetDorm_Label()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Dorm_Label> dormDal = jonghor.Dorm_Label;

            return(dormDal.ToList <Dorm_Label>());
        }
Пример #9
0
        /*public int RoomMax { get; set; }
         * public float RoomPrice { get; set; }
         * public string TypeRoom { get; set; }
         * public int TypeId { get; set; }
         * public string [] RoomOption { get; set; }*/

        //h
        public List <Room_Type> GetRoom_Type()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Room_Type> dormDal = jonghor.Room_Type;

            return(dormDal.ToList <Room_Type>());
        }
Пример #10
0
        public List <Room_Reserved> GetRoomReservedByDormID(int dormId)
        {
            JongHorDBEntities1 db = new JongHorDBEntities1();

            var roomReservedDB = db.Room_Reserved.Where(r => r.Room.Dorm_ID == dormId);

            return(roomReservedDB.ToList <Room_Reserved>());
        }
Пример #11
0
        public List <Room_Reserved> GetRoom_Reserved()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Room_Reserved> dormDal = jonghor.Room_Reserved;

            return(dormDal.ToList <Room_Reserved>());
        }
Пример #12
0
        public List <Dorm_Option> GetDorm_Option()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Dorm_Option> dormDal = jonghor.Dorm_Option;

            return(dormDal.ToList <Dorm_Option>());
        }
Пример #13
0
        public List <Person> GetPeople()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Person> peopleDal = jonghor.Person;

            return(peopleDal.ToList <Person>());
        }
Пример #14
0
        public List <Message> GetMessage()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet <Message> dormDal = jonghor.Message;

            return(dormDal.ToList <Message>());
        }
Пример #15
0
        public List<Dorm_Rate> GetDorm_Rate()
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            DbSet<Dorm_Rate> dormDal = jonghor.Dorm_Rate;

            return dormDal.ToList<Dorm_Rate>();
        }
Пример #16
0
        public Dorm GetDorm(int id)
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            IQueryable <Dorm> dorms = jonghor.Dorm.Where(d => d.Dorm_ID == id);

            if (dorms.ToList <Dorm>().Count != 0)
            {
                return(dorms.ToList <Dorm>()[0]);
            }
            else
            {
                return(new Dorm());
            }
        }
Пример #17
0
        public int GetDormId(string username)
        {
            JongHorDBEntities1 jonghor = new JongHorDBEntities1();

            List <Dorm> dorms = jonghor.Dorm.ToList <Dorm>();

            foreach (Dorm dorm in dorms)
            {
                if (dorm.M_username == username)
                {
                    return(dorm.Dorm_ID);
                }
            }

            return(-1);
        }
Пример #18
0
        //for send message to unavailable room
        public List <Room> GetStatusRoom()
        {
            JongHorDBEntities1 jonghor1 = new JongHorDBEntities1();
            DbSet <Room>       RoomList = jonghor1.Room;

            List <Room> status = new List <Room>();

            foreach (Room r in RoomList)
            {
                if (r.Status == (int)Status.NotAvaliable || r.Status == (int)Status.WaitRoomMate)
                {
                    status.Add(r);
                }
            }


            return(status.ToList <Room>());
        }
Пример #19
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);
        }
Пример #20
0
        public List <Room_Type> GetRoomTypes(Dorm dorm)
        {
            JongHorDBEntities1 db = new JongHorDBEntities1();

            IQueryable <Room> rooms = db.Room.Where(r => r.Dorm_ID == dorm.Dorm_ID);
            List <Room_Type>  types = new List <Room_Type>();

            foreach (Room room in rooms)
            {
                if (!types.Contains(room.Room_Type))
                {
                    types.Add(room.Room_Type);
                }
            }



            return(types);
        }