示例#1
0
        public RoomSeats GetRoomSeats(int roomId)
        {
            SALA      room      = db.SALA.Find(roomId);
            RoomSeats roomSeats = new RoomSeats();

            roomSeats.Room = room;
            var seats = from m in db.MIEJSCE
                        where m.FK_IdSali == roomId
                        select m;
            var query2 = from s in seats
                         orderby s.Rzad
                         select s.Rzad;
            List <int> rowNumbers = query2.Distinct().ToList();

            roomSeats.Rows = new List <SeatsRow>();

            foreach (int n in rowNumbers)
            {
                SeatsRow row = new SeatsRow();
                row.RowNumber  = n;
                row.Seats      = seats.Where(s => s.Rzad == n).ToList();
                row.SeatsCount = seats.Where(s => s.Rzad == n).Count();
                roomSeats.Rows.Add(row);
            }

            roomSeats.RowsCount  = roomSeats.Rows.Count();
            roomSeats.SeatsCount = seats.Count();
            return(roomSeats);
        }
示例#2
0
        public RoomSeats GetRoomSeats(int roomId)
        {
            SALA room = db.SALA.Find(roomId);
            RoomSeats roomSeats = new RoomSeats();
            roomSeats.Room = room;
            var seats = from m in db.MIEJSCE
                        where m.FK_IdSali == roomId
                        select m;
            var query2 = from s in seats
                         orderby s.Rzad
                         select s.Rzad;
            List<int> rowNumbers = query2.Distinct().ToList();

            roomSeats.Rows = new List<SeatsRow>();

            foreach (int n in rowNumbers)
            {
                SeatsRow row = new SeatsRow();
                row.RowNumber = n;
                row.Seats = seats.Where(s => s.Rzad == n).ToList();
                row.SeatsCount = seats.Where(s => s.Rzad == n).Count();
                roomSeats.Rows.Add(row);
            }

            roomSeats.RowsCount = roomSeats.Rows.Count();
            roomSeats.SeatsCount = seats.Count();
            return roomSeats;
        }
示例#3
0
        public SeatsRow GetSeatsRow(int roomId, int rowNr)
        {
            RoomSeats rs  = GetRoomSeats(roomId);
            SeatsRow  row = rs.Rows.FirstOrDefault(r => r.RowNumber == rowNr);

            row.RoomId = roomId;
            return(row);
        }