Example #1
0
        public async Task Should_Return_Event_Type_With_Active_Event()
        {
            // Arrange
            MockEventTypes();

            // Act
            var eventType = await _eventUtilitiesService.GetEventTypeAsync(3, 4);

            // Assert
            Assert.AreEqual(true, eventType.HasActiveEvents);
            Assert.AreEqual("type4", eventType.Name);
        }
Example #2
0
        public async Task <IHttpActionResult> Get(int id)
        {
            if (id == 0)
            {
                return(BadRequest("Invalid request"));
            }

            var organizationId = GetUserAndOrganization().OrganizationId;

            try
            {
                var eventTypeDto = await _eventUtilitiesService.GetEventTypeAsync(organizationId, id);

                var eventTypeViewModel = _mapper.Map <EventTypeDto, EventTypeViewModel>(eventTypeDto);

                return(Ok(eventTypeViewModel));
            }
            catch (ValidationException e)
            {
                return(BadRequestWithError(e));
            }
        }