コード例 #1
0
        public override async Task <GetRoomReply> GetRoom(GetRoomRequest request, ServerCallContext context)
        {
            var room = await _queryRepository.GetById(request.Id);

            var reservation = new RepeatedField <RoomReservation>();

            reservation.AddRange(room.RoomReservations.Select(x => new RoomReservation()
            {
                Id        = x.Id.ToString(),
                StartDate = x.StartDate.ToTimestamp(),
                EndDate   = x.EndDate.ToTimestamp()
            }));
            var result = new GetRoomReply()
            {
                Id          = room.Id.ToString(),
                RoomType    = room.RoomType.ToString(),
                Name        = room.Name,
                Price       = room.Price,
                Reservation = { reservation }
            };

            return(result);
        }
コード例 #2
0
ファイル: CarSvc.cs プロジェクト: thienly/simplekit
        public override async Task <GetCarReply> GetCar(GetCarRequest request, ServerCallContext context)
        {
            var car = await _queryRepository.GetById(request.Id);

            var reservation = new RepeatedField <CarReservation>();

            reservation.AddRange(car.CarReservations.Select(x => new CarReservation()
            {
                StartDate = x.StartDate.ToTimestamp(),
                EndDate   = x.EndDate.ToTimestamp(),
                Id        = x.Id.ToString()
            }));
            var result = new GetCarReply()
            {
                Id              = car.Id.ToString(),
                CarType         = car.CarType.ToString(),
                Name            = car.Name,
                Price           = car.Price,
                CarReservations = { reservation }
            };

            return(result);
        }