public async Task <ActionResult <BoardMeetingViewDto> > GetBoardMeeting([FromRoute] Guid id)
        {
            var boardMeetingFromRepo = await _boardMeetingRepository.GetBoardMeetingAsync(id);

            if (boardMeetingFromRepo == null)
            {
                return(NotFound());
            }

            var boardMeetingToReturn = _mapper.Map <BoardMeetingViewDto>(boardMeetingFromRepo);

            return(Ok(boardMeetingToReturn));
        }
        public async Task <ActionResult <MeetingMinuteViewDto> > CreateMeetingMinute([FromRoute] Guid boardMeetingId, [FromBody] MeetingMinuteInputDto meetingMinuteInputDto)
        {
            if (meetingMinuteInputDto == null)
            {
                return(BadRequest());
            }

            var boardMeeting = await _boardMeetingRepository.GetBoardMeetingAsync(boardMeetingId);

            if (boardMeeting == null)
            {
                return(NotFound());
            }

            if (boardMeeting.MeetingNotes != null)
            {
                return(StatusCode(409, new { Error = "A meeting minute already exists for this board meeting" }));
            }

            //model state validation is not required due to the [ApiController] attribute automatically returning UnprocessableEntity (see startup.cs)
            //when model binding fails

            //fetch the user id from the JWT via HttpContext. Then get the user from the repository. This is to ensure that an authorized user
            //is calling the API with a valid user id
            var user = await _userRepository.GetUserAsync(User.GetUserId());

            if (user == null)
            {
                return(BadRequest(new { Error = "The user was not found in the system. Please try again with an authorized and valid user." }));
            }

            var meetingMinuteToAdd = _mapper.Map <MeetingMinute>(meetingMinuteInputDto); //map EventInputDto to Event

            meetingMinuteToAdd.UserId = user.Id;                                         //set the user id as otherwise navigation property will be null
            await _meetingMinuteRepository.AddMeetingMinute(boardMeetingId, meetingMinuteToAdd);

            if (!await _meetingMinuteRepository.SaveChangesAsync())
            {
                throw new Exception($"Error saving Event {meetingMinuteToAdd.Id} to the database");
            }

            var meetingMinuteToReturn = _mapper.Map <MeetingMinuteViewDto>(meetingMinuteToAdd);

            return(CreatedAtRoute("GetMeetingMinute", new { boardMeetingId = boardMeetingId, id = meetingMinuteToAdd.Id }, meetingMinuteToReturn));
        }