Esempio n. 1
0
 private static void CheckEventDate(CreekEvent @event)
 {
     if (@event.IsInPast())
     {
         throw new UserFriendlyException("Can not register event in the past!");
     }
 }
Esempio n. 2
0
 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());
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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
            });
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 public async Task <EventRegistration> RegisterAsync(CreekEvent @event, User user)
 {
     return(await _eventRegistrationRepository.InsertAsync(
                await EventRegistration.CreateAsync(@event, user, _registrationPolicy)
                ));
 }
Esempio n. 8
0
 public void Cancel(CreekEvent @event)
 {
     @event.Cancel();
     EventBus.Trigger(new EventCancelledEvent(@event));
 }
Esempio n. 9
0
 public async Task CreateAsync(CreekEvent @event)
 {
     await _eventRepository.InsertAsync(@event);
 }