public IActionResult GetList(long id)
        {
            var user = _userService.GetByUserName(User.FindFirstValue(ClaimTypes.Name));

            if (!_jobService.Exists(id))
            {
                return(Ok(new BaseResponse("Job Not Found!")));
            }

            if (user.Role == UserRole.Admin)
            {
                var response = _mapper.Map <JobSubmissionResponse>(_jobSubmissionService.GetByJobId(id).ToList());
                return(Ok(new DataResponse <JobSubmissionResponse>(response)));
            }

            if (user.Role == UserRole.Employeer)
            {
                var job = _jobService.Get(id);

                if (job.ClientId != user.Client.Id)
                {
                    return(Unauthorized());
                }

                var response = _mapper.Map <JobSubmissionResponse>(_jobSubmissionService.GetByJobId(id).ToList());
                return(Ok(new DataResponse <JobSubmissionResponse>(response)));
            }

            var submission = _jobSubmissionService.GetByClientAndJobId(user.Client.Id, id);

            return(Ok(new DataResponse <JobSubmissionResponse>(_mapper.Map <JobSubmissionResponse>(submission))));
        }
        public IActionResult GetList(long id)
        {
            var      clientId = long.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));
            UserRole userRole;

            if (Enum.TryParse(typeof(UserRole), User.FindFirstValue(ClaimTypes.Role), true, out var role))
            {
                userRole = (UserRole)role;
            }
            else
            {
                return(BadRequest());
            }

            if (!_jobService.Exists(id))
            {
                return(NotFound(new BaseResponse("Job Not Found!")));
            }

            // if User is Admin Return all submissions.
            if (userRole == UserRole.Admin)
            {
                var response = _mapper.Map <IEnumerable <JobSubmissionResponse> >(_jobSubmissionService.GetByJobId(id));
                return(Ok(new DataResponse <IEnumerable <JobSubmissionResponse> >(response)));
            }

            // if User is Employeer returns submissions only for his jobs.
            if (userRole == UserRole.Employeer)
            {
                var job = _jobService.Get(id);

                if (job.ClientId != clientId)
                {
                    return(Forbid());
                }

                var response =
                    _mapper.Map <IEnumerable <JobSubmissionResponse> >(_jobSubmissionService.GetByJobId(id));
                return(Ok(new DataResponse <IEnumerable <JobSubmissionResponse> >(response)));
            }

            // if User is FreeLancer return only his submissions.
            var submission = _jobSubmissionService.GetByClientAndJobId(clientId, id);

            return(Ok(new DataResponse <IEnumerable <JobSubmissionResponse> >(
                          _mapper.Map <IEnumerable <JobSubmissionResponse> >(submission))));
        }