public IActionResult GetAllCandidate()
        {
            var user = HttpContext.User;

            if (user.HasClaim(c => c.Type == "Typetoken"))
            {
                if (user.Claims.FirstOrDefault(c => c.Type == "Typetoken").Value == "Login")
                {
                    var result = candidateBL.GetAllCandidate();
                    if (result != null)
                    {
                        var success = true;
                        var message = "All CandidateList getting successfully";
                        return(Ok(new { success, message, result }));
                    }
                    else
                    {
                        var success = false;
                        var message = "candidate getting failed";
                        return(Ok(new { success, message }));
                    }
                }
            }
            return(BadRequest("Used Invalid Token"));
        }
Пример #2
0
        public IActionResult GetAllCandidate()
        {
            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")
                    {
                        List <CandidateAddResponseModel> data = _candidateBusiness.GetAllCandidate();

                        if (data != null)
                        {
                            if (data.Count > 0)
                            {
                                status  = true;
                                message = "Here is the list of all Candidates";
                                return(Ok(new { status, message, data }));
                            }
                            else
                            {
                                message = "No Candidates Present";
                                return(Ok(new { status, message }));
                            }
                        }

                        message = "Unable to Fetch the Candidates";
                        return(Ok(new { status, message }));
                    }
                }
                message = "Invalid Token";
                return(BadRequest(new { status, message }));
            }
            catch (Exception e)
            {
                return(BadRequest(new { e.Message }));
            }
        }