private static void CheckEventDate(CreekEvent @event) { if (@event.IsInPast()) { throw new UserFriendlyException("Can not register event in the past!"); } }
public async Task <IReadOnlyList <User> > GetRegisteredUsersAsync(CreekEvent @event) { return(await _eventRegistrationRepository .GetAll() .Include(registration => registration.User) .Where(registration => registration.EventId == @event.Id) .Select(registration => registration.User) .ToListAsync()); }
public async Task CancelRegistrationAsync(CreekEvent @event, User user) { var registration = await _eventRegistrationRepository.FirstOrDefaultAsync(r => r.EventId == @event.Id && r.UserId == user.Id); if (registration == null) { //No need to cancel since there is no such a registration return; } await registration.CancelAsync(_eventRegistrationRepository); }
public static async Task <EventRegistration> CreateAsync(CreekEvent @event, User user, IEventRegistrationPolicy registrationPolicy) { await registrationPolicy.CheckRegistrationAttemptAsync(@event, user); return(new EventRegistration { TenantId = @event.TenantId, EventId = @event.Id, Event = @event, UserId = @user.Id, User = user }); }
public async Task CheckRegistrationAttemptAsync(CreekEvent @event, User user) { if (@event == null) { throw new ArgumentNullException("event"); } if (user == null) { throw new ArgumentNullException("user"); } CheckEventDate(@event); await CheckEventRegistrationFrequencyAsync(user); }
public static CreekEvent Create(int tenantId, string title, DateTime date, string description = null, int maxRegistrationCount = 0) { var @event = new CreekEvent { Id = Guid.NewGuid(), TenantId = tenantId, Title = title, Description = description, MaxRegistrationCount = maxRegistrationCount }; @event.SetDate(date); @event.Registrations = new Collection <EventRegistration>(); return(@event); }
public async Task <EventRegistration> RegisterAsync(CreekEvent @event, User user) { return(await _eventRegistrationRepository.InsertAsync( await EventRegistration.CreateAsync(@event, user, _registrationPolicy) )); }
public void Cancel(CreekEvent @event) { @event.Cancel(); EventBus.Trigger(new EventCancelledEvent(@event)); }
public async Task CreateAsync(CreekEvent @event) { await _eventRepository.InsertAsync(@event); }