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 }); }
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 }); }
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 }); }
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 }); }
/*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) }; }
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 }); }