Esempio n. 1
0
        public async Task <VenueDocument> UpdateAndGetLatestVenue(VenueDocument updatedVenue)
        {
            VenueDocument venue = await repository.GetVenue(updatedVenue.VenueGuid);

            bool shouldUpdate = false;

            if (venue == null)
            {
                venue        = updatedVenue;
                shouldUpdate = true;
            }
            else
            {
                if (updatedVenue.Description != null &&
                    (venue.Description == null ||
                     venue.Description.ModifiedDate < updatedVenue.Description.ModifiedDate))
                {
                    venue.Description = updatedVenue.Description;
                    shouldUpdate      = true;
                }
                if (updatedVenue.Location != null &&
                    (venue.Location == null ||
                     venue.Location.ModifiedDate < updatedVenue.Location.ModifiedDate))
                {
                    venue.Location = updatedVenue.Location;
                    shouldUpdate   = true;
                }
            }
            if (shouldUpdate)
            {
                await repository.IndexVenue(venue);
            }

            return(venue);
        }
 public void GivenIHaveAVenue(string venueName)
 {
     using (var uow = container.Resolve<IAmAUnitOfWorkFactory>().CreateUnitOfWork())
     {
         venueId = new Id(Guid.NewGuid());
         var venue = new VenueDocument(
             venueId, 
             new Version(), 
             new VenueName("The American Bar, The Savoy Hotel"),
             new Address(new Street("The Strand"), new City("London"), new PostCode("WC2R 0EU")),
             new VenueMap(new Uri("http://www.fairmont.com/savoy/MapAndDirections.htm")),
             new VenueContact(new ContactName("Athena Cripps"), new EmailAddress("*****@*****.**"), new PhoneNumber(" +44 (0)20 7420 2492")));
         uow.Add(venue);
         uow.Commit();
     }
     scheduleMeetingCommand.VenueId = venueId;
 }
        public async Task Handle(ShowAdded showAdded)
        {
            Console.WriteLine($"Indexing a show for {showAdded.act.description.title} at {showAdded.venue.description.name}.");
            try
            {
                string actGuid   = showAdded.act.actGuid.ToString().ToLower();
                string venueGuid = showAdded.venue.venueGuid.ToString().ToLower();

                ActDescription   actDescription   = ActDescription.FromRepresentation(showAdded.act.description);
                VenueDescription venueDescription = VenueDescription.FromRepresentation(showAdded.venue.description);
                VenueLocation    venueLocation    = VenueLocation.FromRepresentation(showAdded.venue.location);

                ActDocument act = await actUpdater.UpdateAndGetLatestAct(new ActDocument
                {
                    ActGuid     = actGuid,
                    Description = actDescription
                });

                VenueDocument venue = await venueUpdater.UpdateAndGetLatestVenue(new VenueDocument
                {
                    VenueGuid   = venueGuid,
                    Description = venueDescription,
                    Location    = venueLocation
                });

                var show = new ShowDocument
                {
                    ActGuid          = actGuid,
                    VenueGuid        = venueGuid,
                    StartTime        = showAdded.show.startTime,
                    ActDescription   = act.Description,
                    VenueDescription = venue.Description,
                    VenueLocation    = venue.Location
                };
                await repository.IndexShow(show);

                Console.WriteLine("Succeeded");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
        public async Task Handle(VenueDescriptionChanged venueDescriptionChanged)
        {
            Console.WriteLine($"Updating index for venue {venueDescriptionChanged.description.name}.");
            try
            {
                string           venueGuid        = venueDescriptionChanged.venueGuid.ToString().ToLower();
                VenueDescription venueDescription = VenueDescription.FromRepresentation(venueDescriptionChanged.description);
                VenueDocument    updatedVenue     = new VenueDocument
                {
                    VenueGuid   = venueGuid,
                    Description = venueDescription
                };
                VenueDocument venue = await venueUpdater.UpdateAndGetLatestVenue(updatedVenue);

                await repository.UpdateShowsWithVenueDescription(venueGuid, venue.Description);

                Console.WriteLine("Succeeded");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
 public Task IndexVenue(VenueDocument venue)
 {
     venues.RemoveAll(v => v.VenueGuid == venue.VenueGuid);
     venues.Add(DeepCopy(venue));
     return(Task.CompletedTask);
 }
Esempio n. 6
0
 public async Task IndexVenue(VenueDocument venue)
 {
     venue.Id = HashOfKey(new { VenueGuid = venue.VenueGuid });
     await elasticClient.IndexDocumentAsync(venue);
 }