private async Task OnRoomViewed(IDenormalizerContext <RoomViewsReadModel> ctx, RoomViewed @event)
 {
     var view = new RoomViewsReadModel
     {
         HotelId      = @event.HotelId,
         ViewId       = @event.ViewId,
         UserId       = @event.UserId,
         RoomType     = @event.RoomType,
         ViewDateTime = @event.TimeStamp
     };
     await ctx.Repository.Save(view, new CancellationToken());
 }
예제 #2
0
 private State Apply(State state, RoomViewed @event)
 {
     return(state);
 }
        private async Task OnRoomViewed(IDenormalizerContext <RoomTemperatureViewsReadModel> ctx, RoomViewed @event)
        {
            var hotel = await ctx.Lookup <Hotel.HotelsReadModel>().GetByIds(@event.HotelId, @event.HotelId, CancellationToken.None);

            var weatherForHotel = await ctx.Lookup <LocationWeather.LocationWeatherReadModel>().GetByKeys(hotel.Location, @event.TimeStamp.Date.ToString("yyyy-MM-dd"), CancellationToken.None);

            var user = await ctx.Lookup <User.UsersReadModel>().GetByIds(@event.UserId, @event.UserId, CancellationToken.None);

            var weatherForUser = await ctx.Lookup <LocationWeather.LocationWeatherReadModel>().GetByKeys(user.Location, @event.TimeStamp.Date.ToString("yyyy-MM-dd"), CancellationToken.None);

            var reservation = new RoomTemperatureViewsReadModel
            {
                HotelId             = @event.HotelId,
                ViewId              = @event.ViewId,
                ReservationDateTime = null,
                ReservationId       = @event.ReservationId,
                ViewDateTime        = @event.TimeStamp,
                HotelLocationTemp   = weatherForHotel.Temperature,
                UserLocationTemp    = weatherForUser.Temperature,
                RoomType            = @event.RoomType
            };
            await ctx.Repository.Save(reservation, new CancellationToken());
        }