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