Esempio n. 1
0
        public HotelRoomsDTO GetHotelRoom(int?id)
        {
            if (id == null)
            {
                throw new ValidationException("Room number is null", "");
            }

            var room = db.HotelRooms.Get(id.Value);

            if (room == null)
            {
                throw new ValidationException("No room with such number", "");
            }

            var classService = new RoomClassesService(new ContextUnitOfWork());
            var roomDTO      = new HotelRoomsDTO()
            {
                RoomNumber    = room.RoomNumber,
                RoomClassCode = room.RoomClassCode,
                Floor         = room.Floor,
                DayCost       = room.DayCost,
                RoomsAmount   = room.RoomsAmount,
                RoomClasses   = classService.GetRoomClass(room.RoomClassCode)
            };

            return(roomDTO);
        }
Esempio n. 2
0
        public IEnumerable <HotelRoomsDTO> GetHotelRooms()
        {
            var hotelRooms    = db.HotelRooms.GetAll();
            var hotelRoomsDTO = new List <HotelRoomsDTO>();
            var classService  = new RoomClassesService(new ContextUnitOfWork());

            foreach (var item in hotelRooms)
            {
                hotelRoomsDTO.Add(new HotelRoomsDTO()
                {
                    RoomNumber    = item.RoomNumber,
                    RoomClassCode = item.RoomClassCode,
                    Floor         = item.Floor,
                    DayCost       = item.DayCost,
                    RoomsAmount   = item.RoomsAmount,
                    RoomClasses   = classService.GetRoomClass(item.RoomClassCode)
                });
            }

            return(hotelRoomsDTO);
        }
Esempio n. 3
0
        public IEnumerable <RoomClassesDTO> GetRoomClasses()
        {
            var classService = new RoomClassesService(new ContextUnitOfWork());

            return(classService.GetRoomClasses());
        }