public async Task <IActionResult> Delete(int id)
        {
            var question = await _questionStore.GetQuestionAsync(id);

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

            if (!await _authorizationService.AuthorizeAsync(User, question.Survey, Operations.Update))
            {
                return(new StatusCodeResult((int)HttpStatusCode.Forbidden));
            }

            await _questionStore.DeleteQuestionAsync(question);

            return(new NoContentResult());
        }
Beispiel #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var question = await _questionStore.GetQuestionAsync(id);

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

            if (!(await _authorizationService.AuthorizeAsync(User, question.Survey, Operations.Update)).Succeeded)
            {
                return(StatusCode(403));
            }

            await _questionStore.DeleteQuestionAsync(question);

            return(NoContent());
        }