Exemple #1
0
        public IEnumerable <VenueDocument> GetAll()
        {
            IRavenQueryable <VenueDocument> venues;

            using (IUnitOfWork unitOfWork = unitOfWorkFactory.CreateUnitOfWork())
            {
                venues = unitOfWork.Query <VenueDocument>();
                if (!allowStale)
                {
                    venues.Customize(x => x.WaitForNonStaleResultsAsOfLastWrite());
                }
            }

            return(venues);
        }
        public override DeleteVenueCommand Handle(DeleteVenueCommand command)
        {
            using (IUnitOfWork uow = unitOfWorkFactory.CreateUnitOfWork())
            {
                var venue = repository[command.Id];
                repository.Delete(venue);

                uow.Commit();
            }

            return(base.Handle(command));
        }
 public override UpdateVenueCommand Handle(UpdateVenueCommand command)
 {
     using (var uow = unitOfWorkFactory.CreateUnitOfWork())
     {
         repository.UnitOfWork = uow;
         var venue = repository[command.Id];
         if (venue.Version != command.Version)
         {
             throw new OptimisticConcurrencyException(string.Format("Expected version {0}, but aggregate is at version {1})", command.Version, venue.Version));
         }
         venue.Update(command.VenueName, command.Address, command.Contact, command.VenueMap);
         uow.Commit();
     }
     return(base.Handle(command));
 }
Exemple #4
0
        public override ScheduleMeetingCommand Handle(ScheduleMeetingCommand command)
        {
            var meeting = scheduler.Schedule(
                new Id(command.MeetingId),
                new MeetingDate(command.On),
                new Id(command.VenueId),
                new Id(command.SpeakerId),
                new Capacity(command.Capacity));

            using (var unitOfWork = unitOfWorkFactory.CreateUnitOfWork())
            {
                repository.UnitOfWork = unitOfWork;
                repository.Add(meeting);
                unitOfWork.Commit();
            }

            return(base.Handle(command));
        }
Exemple #5
0
        public override AddVenueCommand Handle(AddVenueCommand command)
        {
            var venue = new Venue(
                version: new Version(),
                name: command.VenueName,
                address: command.Address,
                map: command.VenueMap,
                contact: command.Contact);

            using (var unitOfWork = unitOfWorkFactory.CreateUnitOfWork())
            {
                repository.UnitOfWork = unitOfWork;
                repository.Add(venue);
                unitOfWork.Commit();
            }

            command.Id = venue.Id;

            return(base.Handle(command));
        }
Exemple #6
0
        public override AddSpeakerCommand Handle(AddSpeakerCommand command)
        {
            var speaker = new Speaker(
                phoneNumber: new PhoneNumber(command.PhoneNumber),
                bio: new SpeakerBio(command.Bio),
                emailAddress: new EmailAddress(command.Email),
                name: new SpeakerName(command.Name)
                );

            using (IUnitOfWork unitOfWork = unitOfWorkFactory.CreateUnitOfWork())
            {
                repository.UnitOfWork = unitOfWork;
                repository.Add(speaker);
                unitOfWork.Commit();
            }

            command.Id = speaker.Id;

            return(base.Handle(command));
        }