public async Task <ActionResult> Delete(int id, [Bind("Id,Title,Owner")] Todo todo) { if (User.IsInRole("Writer")) { await _todoListService.DeleteAsync(id); } return(RedirectToAction("Index")); }
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")); }
public async Task <IActionResult> DeleteAsync(Guid id) { return(Ok(ApiResult <BaseResponseModel> .Success(await _todoListService.DeleteAsync(id)))); }