コード例 #1
0
        public IActionResult DeleteCandidate(int CandidateId)
        {
            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 = _candidateBusiness.DeleteCandidate(CandidateId);

                        if (status)
                        {
                            message = "Candidate has been Deleted Successfully";
                            return(Ok(new { status, message }));
                        }
                        message = "Unable to Delete the Candidate";
                        return(Ok(new { status, message }));
                    }
                }
                message = "Invalid Token";
                return(BadRequest(new { status, message }));
            }
            catch (Exception e)
            {
                return(BadRequest(new { e.Message }));
            }
        }
コード例 #2
0
        public IActionResult DeleteCandidate(int CandidateId)
        {
            var user = HttpContext.User;

            if (user.HasClaim(c => c.Type == "Typetoken"))
            {
                if (user.Claims.FirstOrDefault(c => c.Type == "Typetoken").Value == "Login")
                {
                    var result = candidateBL.DeleteCandidate(CandidateId);
                    if (result != null)
                    {
                        var success = true;
                        var message = "Candidate Deleted successfully";
                        return(Ok(new { success, message, result }));
                    }
                    else
                    {
                        var success = false;
                        var message = "candidate deletion failed";
                        return(Ok(new { success, message, result }));
                    }
                }
            }
            return(BadRequest("Used Invalid Token"));
        }