public IActionResult Get(Guid id)
        {
            IActionResult result = null;

            if (result == null && id.Equals(Guid.Empty))
            {
                result = BadRequest("Missing id");
            }

            if (result == null)
            {
                using (ILifetimeScope scope = m_container.BeginLifetimeScope())
                {
                    IInvitationFactory factory    = scope.Resolve <IInvitationFactory>();
                    IInvitation        invitation = factory.Get(m_settings.Value, id);
                    if (invitation == null)
                    {
                        result = NotFound();
                    }
                    else
                    {
                        IMapper mapper = new Mapper(m_mapperConfiguration);
                        result = Ok(mapper.Map <Models.Invitation>(invitation));
                    }
                }
            }
            return(result);
        }
        public IActionResult Update([FromBody] Models.Invitation invitation)
        {
            IActionResult result          = null;
            IMapper       mapper          = null;
            IInvitation   innerInvitation = null;

            if (result == null && invitation == null)
            {
                result = BadRequest("Missing invitation data");
            }

            if (result == null && (!invitation.InvitationId.HasValue || invitation.InvitationId.Equals(Guid.Empty)))
            {
                result = BadRequest("Missing id");
            }

            if (result == null && !invitation.EventDate.HasValue)
            {
                result = BadRequest("Missing event date");
            }

            if (result == null && !invitation.RSVPDueDate.HasValue)
            {
                result = BadRequest("Missing RSVP date");
            }

            if (result == null && string.IsNullOrEmpty(invitation.Title))
            {
                result = BadRequest("Missing title");
            }

            if (result == null && string.IsNullOrEmpty(invitation.Invitee))
            {
                result = BadRequest("Missing invitee");
            }

            if (result == null)
            {
                mapper = new Mapper(m_mapperConfiguration);
                using (ILifetimeScope scope = m_container.BeginLifetimeScope())
                {
                    IInvitationFactory factory = scope.Resolve <IInvitationFactory>();
                    innerInvitation = factory.Get(m_settings.Value, invitation.InvitationId.Value);

                    if (innerInvitation == null)
                    {
                        result = NotFound();
                    }
                    else
                    {
                        mapper.Map <Models.Invitation, IInvitation>(invitation, innerInvitation);
                        IInvitationSaver saver = scope.Resolve <IInvitationSaver>();
                        saver.Update(m_settings.Value, innerInvitation);
                        invitation = mapper.Map <Models.Invitation>(innerInvitation);
                        result     = Ok(invitation);
                    }
                }
            }
            return(result);
        }
        public IActionResult CreateResponse(Guid id, [FromBody] Models.InvitationResponse response)
        {
            IActionResult result = null;

            if (result == null && id.Equals(Guid.Empty))
            {
                result = BadRequest("Missing id");
            }

            if (result == null && response == null)
            {
                result = BadRequest("Missing response data");
            }

            if (result == null)
            {
                using (ILifetimeScope scope = m_container.BeginLifetimeScope())
                {
                    IInvitationFactory factory    = scope.Resolve <IInvitationFactory>();
                    IInvitation        invitation = factory.Get(m_settings.Value, id);
                    if (invitation == null)
                    {
                        result = NotFound();
                    }
                    else
                    {
                        IInvitationResponse      innerResponse = invitation.CreateResponse(response.IsAttending, response.AttendeeCount, response.Note);
                        IInvitationResponseSaver saver         = scope.Resolve <IInvitationResponseSaver>();
                        saver.Create(m_settings.Value, innerResponse);
                        IMapper mapper = new Mapper(m_mapperConfiguration);
                        result = Ok(mapper.Map <Models.InvitationResponse>(innerResponse));
                    }
                }
            }
            return(result);
        }