Esempio n. 1
0
        public async Task <IActionResult> DeclineInvitationAsync(InvitationId invitationId)
        {
            var userId = HttpContext.GetUserId();

            var invitation = await _invitationService.FindInvitationAsync(invitationId);

            if (invitation == null)
            {
                return(this.NotFound("The invitation was not found."));
            }

            var result = await _invitationService.DeclineInvitationAsync(invitation, userId);

            if (result.IsValid)
            {
                return(this.Ok("The invitation has been declined."));
            }

            result.AddToModelState(ModelState);

            return(this.BadRequest(new ValidationProblemDetails(ModelState)));
        }