public IActionResult DeleteConstituency(int ConstituencyId) { try { var admin = HttpContext.User; bool status = false; string message; if (admin.HasClaim(c => c.Type == "TokenType")) { if (admin.Claims.FirstOrDefault(c => c.Type == "TokenType").Value == "Login") { status = _constituencyBusiness.DeleteConstituency(ConstituencyId); if (status) { message = "Constituency has been Deleted Successfully"; return(Ok(new { status, message })); } message = "Unable to Delete the Constituency"; return(Ok(new { status, message })); } } message = "Invalid Token"; return(BadRequest(new { status, message })); } catch (Exception e) { return(BadRequest(new { e.Message })); } }
public IActionResult DeleteConstituency(int constituencyId) { var user = HttpContext.User; if (user.HasClaim(c => c.Type == "Typetoken")) { if (user.Claims.FirstOrDefault(c => c.Type == "Typetoken").Value == "Login") { var result = constituencyBL.DeleteConstituency(constituencyId); if (result != null) { var success = true; var message = "Constituency Deleted"; return(Ok(new { success, message })); } else { var success = false; var message = "Constituency deletion failed"; return(Ok(new { success, message })); } } } return(BadRequest("Used Invalid Token")); }