public async Task <bool> CreateRegistrationForEvent(int eventId, int userId) { Event item = await eventRepository.ReadAsync(eventId); // if max number of registrations has been reached if (item.EventRegistrations.Count() >= item.MaxRegistrations) { return(false); } // create new registration Registration newRegistration = new Registration { UserId = userId, EventId = eventId }; // save registration await eventRepository.CreateRegistrationForEvent(newRegistration); return(true); }