public async Task<ApiResult<SurveyDTO>> UpdateSurveyAsync(SurveyDTO survey)
 {
     var path = $"/surveys/{survey.Id}";
     var response = await _httpClient.SendRequestWithBearerTokenAsync(HttpMethod.Put, path, survey,
                 await _surveysTokenService.GetTokenForWebApiAsync(_httpContextAccessor.HttpContext.User)
                         .ConfigureAwait(false), _cancellationToken);
     return await ApiResult<SurveyDTO>.FromResponseAsync(response).ConfigureAwait(false);
 }
 public async Task<IActionResult> Create(SurveyDTO survey)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var result = await _surveyService.CreateSurveyAsync(survey);
             if (result.Succeeded)
             {
                 return RedirectToAction("Edit", new { id = result.Item.Id });
             }
             else
             {
                 ModelState.AddModelError(string.Empty, $"Unable to create survey. (HTTP {result.StatusCode})");
                 switch (result.StatusCode)
                 {
                     case (int)HttpStatusCode.Unauthorized:
                         return ReAuthenticateUser();
                     case (int)HttpStatusCode.Forbidden:
                         ViewBag.Forbidden = true;
                         return View(survey);
                     default:
                         return View(survey);
                 }
             }
         }
         else
         {
             ModelState.AddModelError(string.Empty, "Bad Request");
             return View(survey);
         }
     }
     catch (AuthenticationException)
     {
         return ReAuthenticateUser();
     }
     catch
     {
         ModelState.AddModelError(string.Empty, "Unable to create survey.");
     }
     return View("~/Views/Shared/Error.cshtml");
 }
 public IActionResult Create()
 {
     var survey = new SurveyDTO();
     return View(survey);
 }