Esempio n. 1
0
 public async Task <ActionResult> Delete(int id, [Bind("Id,Title,Owner")] Todo todo)
 {
     if (User.IsInRole("Writer"))
     {
         await _todoListService.DeleteAsync(id);
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 2
0
        public async Task <ActionResult> Delete(int id, [Bind("Id,Title,Owner")] Todo todo)
        {
            try
            {
                await _todoListService.DeleteAsync(id);
            }
            catch (WebApiMsalUiRequiredException hex)
            {
                // Challenges the user if exception is thrown from Web API.
                try
                {
                    var claimChallenge = ExtractAuthenticationHeader.ExtractHeaderValues(hex);
                    _consentHandler.ChallengeUser(new string[] { "user.read" }, claimChallenge);
                    return(new EmptyResult());
                }
                catch (Exception ex)
                {
                    _consentHandler.HandleException(ex);
                }

                Console.WriteLine(hex.Message);
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 public async Task <IActionResult> DeleteAsync(Guid id)
 {
     return(Ok(ApiResult <BaseResponseModel> .Success(await _todoListService.DeleteAsync(id))));
 }