Example #1
0
        public async Task <IActionResult> RespondInvitationAsync(
            [FromRoute] string email,
            [FromRoute] int invitationId,
            [FromBody] RespondInvitationRequest respondInvitationRequest)
        {
            if (respondInvitationRequest.InvitationStatus != InvitationStatus.NotReplied)
            {
                // TODO check if is a logged user`s invitation
                var member = await _membersService.GetMemberByEmail(email);

                if (member == null)
                {
                    return(BadRequest());
                }

                await _membersService.RespondInvitation(
                    invitationId,
                    respondInvitationRequest.InvitationStatus,
                    member);

                await _membersService.SaveChangesAsync();

                return(Ok());
            }

            return(BadRequest());
        }