public static async Task <Room> GetRoomByBookingId(this IMongoQueryRepository <Room> queryRepository, Guid bookingId)
        {
            var filterBuilder    = new FilterDefinitionBuilder <Room>();
            var filterDefinition = filterBuilder.Where(c => c.RoomReservations.Any(r => r.Id == bookingId));
            var car = (await queryRepository.GetCollection().FindAsync(filterDefinition)).First();

            return(car);
        }
        public static async Task <Room> GetById(this IMongoQueryRepository <Room> queryRepository, Guid id)
        {
            var filterBuilder    = new FilterDefinitionBuilder <Room>();
            var filterDefinition = filterBuilder.Eq(c => c.Id, id);
            var car = (await queryRepository.GetCollection().FindAsync(filterDefinition)).First();

            return(car);
        }
示例#3
0
        public override async Task <ListOfRoomReply> ListOfRoom(ListOfRoomRequest request, ServerCallContext context)
        {
            var listAsync = await _queryRepository.GetCollection().AsQueryable().ToListAsync();

            var result = new ListOfRoomReply();

            listAsync.ForEach(x =>
            {
                result.Rooms.Add(new RoomMessage()
                {
                    Id       = x.Id.ToString(),
                    Name     = x.Name,
                    Price    = x.Price,
                    RoomType = x.RoomType.ToString()
                });
            });
            return(result);
        }