Example #1
0
        public async Task <IActionResult> Delete(int id)
        {
            var survey = await _surveyStore.GetSurveyAsync(id);

            if (survey == null)
            {
                return(HttpNotFound());
            }

            // Validate that the current user has Delete permissions to this survey.
            if (!await _authorizationService.AuthorizeAsync(User, survey, Operations.Delete))
            {
                return(new HttpStatusCodeResult((int)HttpStatusCode.Forbidden));
            }

            await _surveyStore.DeleteSurveyAsync(survey);

            return(new ObjectResult(DataMapping._surveyToDto(survey)));
        }
Example #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var survey = await _surveyStore.GetSurveyAsync(id);

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

            // Validate that the current user has Delete permissions to this survey.
            if (!(await _authorizationService.AuthorizeAsync(User, survey, Operations.Delete)).Succeeded)
            {
                return(StatusCode(403));
            }

            await _surveyStore.DeleteSurveyAsync(survey);

            return(Ok(DataMapping._surveyToDto(survey)));
        }