Exemplo n.º 1
0
        public async Task <IActionResult> Publish(int id)
        {
            var survey = await _surveyStore.GetSurveyAsync(id);

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

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

            var published = await _surveyStore.PublishSurveyAsync(id);

            return(new ObjectResult(DataMapping._surveyToDto(published)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Publish(int id)
        {
            var survey = await _surveyStore.GetSurveyAsync(id);

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

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

            var published = await _surveyStore.PublishSurveyAsync(id);

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