コード例 #1
0
        public void ChangeSubject(OrganizerId organizerId, Subject subject)
        {
            if (Version == -1)
            {
                throw new MeetupNotFoundException();
            }

            if (Completed)
            {
                throw new MeetupCompletedException();
            }

            if (Cancelled)
            {
                throw new MeetupCancelledException();
            }

            if (organizerId != OrganizerId)
            {
                throw new MeetupDomainException("You are not organizer this meetup");
            }

            if (Subject == subject)
            {
                return;
            }

            ApplyEvent(new MeetupSubjectChanged
            {
                MeetupId    = Id,
                Subject     = subject,
                ChangedDate = DateTime.Now
            });
        }
コード例 #2
0
        public void Complete(OrganizerId organizerId)
        {
            if (Version == -1)
            {
                throw new MeetupNotFoundException();
            }

            if (Completed)
            {
                throw new MeetupCompletedException();
            }

            if (Cancelled)
            {
                throw new MeetupCancelledException();
            }

            if (organizerId != OrganizerId)
            {
                throw new MeetupDomainException("You are not organizer this meetup");
            }

            ApplyEvent(new MeetupCompleted
            {
                MeetupId    = Id,
                CreatedDate = DateTime.Now
            });
        }
コード例 #3
0
        public void ChangeAddress(OrganizerId organizerId, Address address)
        {
            if (Version == -1)
            {
                throw new MeetupNotFoundException();
            }

            if (Completed)
            {
                throw new MeetupCompletedException();
            }

            if (Cancelled)
            {
                throw new MeetupCancelledException();
            }

            if (organizerId != OrganizerId)
            {
                throw new MeetupDomainException("You are not organizer this meetup");
            }

            if (Location.Address == address)
            {
                return;
            }

            ApplyEvent(new MeetupAddressChanged
            {
                MeetupId    = Id,
                Address     = address,
                ChangedDate = DateTime.Now
            });
        }
コード例 #4
0
        public void ChangeDescription(OrganizerId organizerId, Description description)
        {
            if (Version == -1)
            {
                throw new MeetupNotFoundException();
            }

            if (Completed)
            {
                throw new MeetupCompletedException();
            }

            if (Cancelled)
            {
                throw new MeetupCancelledException();
            }

            if (organizerId != OrganizerId)
            {
                throw new MeetupDomainException("You are not organizer this meetup");
            }

            if (Description == description)
            {
                return;
            }

            ApplyEvent(new MeetupDescriptionChanged
            {
                MeetupId    = Id,
                Description = description,
                ChangedDate = DateTime.Now
            });
        }
コード例 #5
0
 /*Event Handlers*/
 private void OnRegistered(MeetupRegistered @event)
 {
     Id          = new MeetupId(@event.MeetupId);
     OrganizerId = new OrganizerId(@event.OrganizerId);
     Subject     = new Subject(@event.Subject);
     When        = new When(@event.When);
     Description = new Description(@event.Description);
     Location    = new Location
     {
         Address = new Address(@event.Address)
     };
 }
コード例 #6
0
        public async Task Register(MeetupId meetupId, OrganizerId organizerId, Subject subject, When when, Description description, Address address, IMeetupPolicy policy)
        {
            if (Version >= 0)
            {
                throw new MeetupAlreadyRegisteredException();
            }

            await policy.CheckCanDefineMeetupAsync(organizerId, when);

            ApplyEvent(new MeetupRegistered
            {
                MeetupId    = meetupId,
                OrganizerId = organizerId,
                Subject     = subject,
                When        = when,
                Description = description,
                Address     = address,
                CreatedDate = DateTime.Now
            });
        }