public async Task <IActionResult> CreateEventOfferingRegistration([FromBody] EventOfferingRegistrationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var created = await eventOfferingRegistrationService.CreateEventOfferingRegistrationAsync(model);

                return(CreatedAtAction(nameof(GetEventOfferingRegistrationById), new { eventOfferingRegistrationId = created.Id }, created));
            }
            catch (Exception e)
            {
                return(await HandleControllerException(e));
            }
        }
        public async Task CanAddALocation()
        {
            var toAdd = new EventOfferingRegistrationViewModel
            {
                EventOfferingId = "1",
                UserId          = "3"
            };

            eventOfferingRegistrationService.Setup(repo => repo.CreateEventOfferingRegistrationAsync(toAdd)).ReturnsAsync(CreateTestEventOfferingRegistration(toAdd));
            eventOfferingRegistrationService.Setup(repo => repo.GetEventOfferingRegistrationsAsync()).ReturnsAsync(GetTestEventOfferingRegistrations());

            var result = await controller.GetEventOfferingRegistrations();

            // Assertions
            Assert.IsInstanceOf <ActionResult <IList <Entities.EventOfferingRegistration> > >(result);
            var resultObject = GetObjectResultContent(result);

            Assert.AreEqual(3, resultObject.Count);
        }
        public async Task<EventOfferingRegistration> CreateEventOfferingRegistrationAsync(EventOfferingRegistrationViewModel model)
        {
            try
            {
                var eventOfferingRegistration = mapper.Map<EventOfferingRegistration>(model);

                var created = await repository.CreateEventOfferingRegistrationAsync(eventOfferingRegistration);

                return await SaveAndReturn(created);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        private Entities.EventOfferingRegistration CreateTestEventOfferingRegistration(EventOfferingRegistrationViewModel model)
        {
            var created = new Entities.EventOfferingRegistration
            {
                Id = "2",
                EventOfferingId = model.EventOfferingId,
                UserId          = model.UserId
            };

            eventOfferingRegistrations.Add(created);

            return(created);
        }