Пример #1
0
        public IActionResult Get(string textBoxSearch, RoomSearch roomSearch)
        {
            if (textBoxSearch == null)
            {
                return(Ok());
            }

            if (roomSearch == RoomSearch.ByRoomLabelorRoomUse)
            {
                return(Ok(_roomService.GetRoomsByRoomLabelorRoomUse(textBoxSearch.ToLower().Trim())));
            }
            else if (roomSearch == RoomSearch.ByRoomId)
            {
                if (Int32.TryParse(textBoxSearch, out int id))
                {
                    return(Ok(_roomService.GetRoomById(id)));
                }
                else
                {
                    return(Ok());
                }
            }
            else if (roomSearch == RoomSearch.ByEquipment)
            {
                return(Ok(_roomService.GetAllRoomsByEquipment(Int32.Parse(textBoxSearch))));
            }
            else if (roomSearch == RoomSearch.ByRoomNumber)
            {
                return(Ok(_roomService.GetNeighbouringRoom(Int32.Parse(textBoxSearch))));
            }
            else
            {
                return(Ok());
            }
        }
Пример #2
0
        public ActionResult Index(DateTime?startDate, DateTime?endDate, int?persons, bool?error)
        {
            if (startDate.HasValue && endDate.HasValue && persons.HasValue)
            {
                var availableRooms =
                    db.Rooms.Where(r => r.MaxPeople >= persons)
                    .Where(r => r.Reservations.Where(s => (s.EndDate > startDate && s.EndDate <= endDate) || (s.StartDate < endDate && s.StartDate >= startDate))
                           .Count() == 0).ToList();

                var model = new RoomSearch
                {
                    Rooms     = availableRooms,
                    StartDate = startDate,
                    EndDate   = endDate,
                    Persons   = persons
                };

                return(View(model));
            }
            else
            {
                var allRooms = db.Rooms.ToList();
                var model    = new RoomSearch
                {
                    Rooms     = allRooms,
                    StartDate = DateTime.Today,
                    EndDate   = DateTime.Today.AddDays(1),
                    Persons   = 2
                };

                return(View(model));
            }
        }
Пример #3
0
        /* RAW SQL QUERY WORKING PROTOTYPE.
         * SELECT Room.ID, Level, BedCount, Booking.CheckIn, Booking.CheckOut, Booking.CustomerEmail
         *  FROM Room
         *  LEFT JOIN Booking
         *  ON Room.ID = Booking.RoomID
         *  WHERE Room.ID NOT IN (
         *          SELECT Room.ID
         *          FROM Room
         *          LEFT JOIN Booking
         *          ON Room.ID = Booking.RoomID
         *          WHERE (date('2019-09-12 00:00:00') >= date(checkIn) and date('2019-09-12 00:00:00') <= date(checkOut)) or (date('2019-09-15 00:00:00') <= date(checkOut) and date('2019-09-15 00:00:00') >= date(CheckIn))
         *      )
         */
        public async Task <IActionResult> SearchRooms([Bind("BedCount", "CheckIn", "CheckOut")] RoomSearch searchParameters)//
        {
            if (searchParameters.CheckIn.DaysOfStay(searchParameters.CheckOut) < 1)
            {
                return(View(new Models.RoomSearch()));
            }
            string query = "SELECT Room.ID, Level, BedCount, Booking.CheckIn, Booking.CheckOut, Booking.CustomerEmail, Room.Price " +
                           "FROM Room LEFT JOIN Booking ON Room.ID = Booking.RoomID " +
                           "WHERE BedCount = @BEDSNEEDED AND " +
                           "Room.ID NOT IN(    " +
                           "SELECT Room.ID " +
                           "FROM Room " +
                           "LEFT JOIN Booking " +
                           "ON Room.ID = Booking.RoomID " +
                           "WHERE (date(@INCOMINGSTART) >= date(checkIn) and date(@INCOMINGSTART) <= date(checkOut)) or (date(@INCOMINGEND) <= date(checkOut) and date(@INCOMINGEND) >= date(CheckIn)))";
            var occupationStart = new SqliteParameter("INCOMINGSTART", searchParameters.CheckIn);
            var occupationEnd   = new SqliteParameter("INCOMINGEND", searchParameters.CheckOut);
            var bedsNeeded      = new SqliteParameter("BEDSNEEDED", searchParameters.BedCount);
            var freeRooms       = await _context.Room.FromSql(query, occupationStart, occupationEnd, bedsNeeded).ToListAsync();

            var newSearch = new Models.RoomSearch
            {
                AvailableRooms = freeRooms
            };

            return(View("~/Views/SearchRooms/SearchRooms.cshtml", newSearch));
        }
Пример #4
0
        public ActionResult Index(RoomSearch search)
        {
            var rooms = new List <room>();

            if (search.Start != null && search.End != null)
            {
                rooms.AddRange(roomService.FindAvailable(search.Start, search.End));
            }
            else
            {
                rooms.AddRange(roomService.GetAll());
            }

            if (search.Beds != 0)
            {
                rooms = rooms.FindAll(t => t.beds == search.Beds);
            }
            if (!string.IsNullOrEmpty(search.Quality))
            {
                rooms = rooms.FindAll(room => room.quality == search.Quality);
            }


            var model = new RoomSearchIndexModel
            {
                Results = rooms,
            };

            return(View(model));
        }
        public async Task ShowResultAsync(RoomSearch roomSearch)
        {
            _showResult = true;

            roomDatas = await SearchService.SearchRoomAsync(roomSearch);

            StateHasChanged();
        }
        private void RoomCommandData(object obj)
        {
            var roomSearch = new RoomSearch
            {
                RoomID = Model.RoomId
            };

            Model.RoomTable = roomSearch.Search();
        }
Пример #7
0
        public IActionResult Index()
        {
            var roomsearch = new RoomSearch
            {
                Cities    = (_context.Room.Select(t => t.City).Distinct()).ToList(),
                RoomTypes = (_context.RoomType.Select(t => t.RoomType1)).ToList()
            };

            return(View(roomsearch));
        }
Пример #8
0
        public PagedResponse <RoomDto> Execute(RoomSearch search)
        {
            var roomsQuery = this.context.Rooms
                             .AsQueryable();

            if (search.HotelId != 0)
            {
                roomsQuery = roomsQuery.Where(r => r.HotelId == search.HotelId);
            }

            var rooms = this.mapper.Map <List <RoomDto> >(roomsQuery.FormatForPagedResponse(search));

            return(rooms.GeneratePagedResponse(search, roomsQuery));
        }
Пример #9
0
        public IQueryable <Room> GetRooms(RoomSearch search)
        {
            // Validate
            search.Should().NotBeNull();
            search.SearchText.Should().NotBeNullOrWhiteSpace();

            // Build query
            IQueryable <Room> query = _context.Rooms.Where(r => r.Name.Contains(search.SearchText) || r.Description.Contains(search.SearchText));

            if (search.IsDeleted.HasValue)
            {
                query = query.Where(r => r.IsDeleted == search.IsDeleted);
            }

            return(query.Take(search.MaxResults));
        }
Пример #10
0
        public async Task <IActionResult> SearchRooms(RoomSearch roomSearch)
        {
            // prepare the parameters to be inserted into the query

            var totalBeds = new SqliteParameter("bedCount", roomSearch.BedCount);
            var cInDate   = new SqliteParameter("checkIn", roomSearch.CheckIn);
            var cOutDate  = new SqliteParameter("checkOut", roomSearch.CheckOut);

            var searchRoom = _context.Room.FromSql("select * from [Room]"
                                                   + "where [Room].BedCount = @bedCount and [Room].ID not in " +
                                                   "(select [Room].ID from [Room] inner join [Booking] on [Room].ID = [Booking].RoomID " +
                                                   "where ([Booking].checkIn <= @checkIn and [Booking].checkOut >= @checkIn)" +
                                                   "or ([Booking].checkIn >= @checkIn and[Booking].checkOut <= @checkOut)" +
                                                   "or ([Booking].checkIn <= @checkOut and [Booking].checkOut >= @checkOut))", totalBeds, cInDate, cOutDate).Select(ro => new Room {
                ID = ro.ID, Level = ro.Level, BedCount = ro.BedCount, Price = ro.Price
            });

            ViewBag.Results = await searchRoom.ToListAsync();

            return(View(roomSearch));
        }
Пример #11
0
        public override bool Enact()
        {
            //Debug.Log(name + " enacting aimed walk");

            if (!ValidatePath)
            {
                SetNewAim();
                path = RoomSearch.FindShortestPath(Tower.ActiveRoom, monster.position, _aim);

                pathPosition = -1;
            }
            pathPosition++;
            if (pathPosition < path.Length - pathTruncation)
            {
                monster.lookDirection = path[pathPosition] - monster.position;
                monster.RequestMove(path[pathPosition]);
            }

            base.Enact();
            return(false);
        }
Пример #12
0
        public async Task <List <RoomData> > SearchRoomAsync(RoomSearch query)
        {
            await Task.Delay(2000);

            var roomDataQuery =
                from rt in _roomRepo.RoomTypes
                join dorm in _dormRepo.Dormitories
                on rt.DormitoryId equals dorm.Id
                //where rt.Beds == query.Beds && rt.Type == query.Type
                select new RoomData
            {
                City          = dorm.City,
                Beds          = rt.Beds,
                DormitoryName = dorm.Name,
                Price         = rt.Price,
                Id            = rt.Id,
                FromDate      = query.CheckInTime,
                ToDate        = query.CheckOutTime,
            };

            return(roomDataQuery.ToList());
        }
Пример #13
0
 public IActionResult Get([FromQuery] RoomSearch search,
                          [FromServices] IGetRoomsQuery getRoomsQuery)
 {
     return(Ok(_dispatcher.DispatchQuery(getRoomsQuery, search)));
 }
Пример #14
0
 public void OnTriggerExit2D(RoomSearch other)
 {
     roomFound = false;
 }
Пример #15
0
 public void OnTriggerEnter2D(RoomSearch other)
 {
     roomFound = true;
 }
Пример #16
0
 async Task OnRoomSearched(RoomSearch roomSearch)
 {
     await result.ShowResultAsync(roomSearch);
 }