public IActionResult GetConstituencyById(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") { ConstituencyAddResponseModel data = _constituencyBusiness.GetConstituencyById(ConstituencyId); if (data != null) { status = true; message = "Constituency Details has been Successfully fetched"; return(Ok(new { status, message, data })); } message = "Unable to get the specificed Constituency Details"; return(Ok(new { status, message })); } } message = "Invalid Token"; return(BadRequest(new { status, message })); } catch (Exception e) { return(BadRequest(new { e.Message })); } }
public IActionResult GetConstituencyById(int constituencyId) { var user = HttpContext.User; ConstituencyResponseModel result = new ConstituencyResponseModel(); if (user.HasClaim(c => c.Type == "Typetoken")) { if (user.Claims.FirstOrDefault(c => c.Type == "Typetoken").Value == "Login") { result = constituencyBL.GetConstituencyById(constituencyId); if (result != null) { var success = true; var message = "Getting single record By Id successful"; return(Ok(new { success, message, result })); } else { var success = false; var message = "Getting single record By Id failed"; return(Ok(new { success, message })); } } } return(BadRequest("Used Invalid Token")); }