public IActionResult AddCandidate(CandidateRequestModel requestModel) { var user = HttpContext.User; if (user.HasClaim(c => c.Type == "Typetoken")) { if (user.Claims.FirstOrDefault(c => c.Type == "Typetoken").Value == "Login") { var result = candidateBL.AddCandidate(requestModel); if (result != null) { var success = true; var message = "Candidate ADD successfully"; return(Ok(new { success, message, result })); } else { var success = false; var message = "candidate add failed"; return(Ok(new { success, message, result })); } } } return(BadRequest("Used Invalid token")); }
public IActionResult AddCandidate(AddCandidateRequestModel addCandidate) { 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") { AddCandidateResponseModel candidateResponse = _candidateBusiness.AddCandidate(addCandidate); if (candidateResponse != null) { if (candidateResponse.ErrorResponse.ErrorStatus) { message = candidateResponse.ErrorResponse.Message; return(Ok(new { status, message })); } else { status = true; message = "Candidate Has Been Successfully Added to City."; CandidateAddResponseModel data = candidateResponse.CandidateAdd; return(Ok(new { status, message, data })); } } message = "Unable to Add Candidate."; return(Ok(new { status, message })); } } message = "Invalid Token"; return(BadRequest(new { status, message })); } catch (Exception e) { return(BadRequest(new { e.Message })); } }