Ejemplo n.º 1
0
        public async Task <ActionResult <JobStatusResponse> > SubmitJob([FromBody] JobSubmitRequest request)
        {
            _eventTracker.TrackInfo("SubmitJob", "Submitting a new job", request);
            if (User.Identity.Name == null)
            {
                _eventTracker.TrackInfo("SubmitJob", "Unauthorized attempt to list all jobs");
                return(Unauthorized());
            }

            if (request.Attributes == null)
            {
                request.Attributes = new Dictionary <string, Dictionary <string, string> >();
            }

            var jobSubmit = new JobSubmit
            {
                JobName    = request.JobName,
                TopicQuery = request.TopicQuery,
                SelectedAcquirersIdentifiers = request.SelectedAcquirers,
                SelectedAnalysersIdentifiers = request.SelectedAnalysers,
            };

            var jobStatus = await _jobManagementService.SubmitJob(jobSubmit, request.Attributes);

            var response = new JobStatusResponse
            {
                JobId  = jobStatus.JobId,
                Status = jobStatus.Status,
            };

            _eventTracker.TrackInfo("SubmitJob", "New job submitted", response);
            return(Ok(response));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateJobPosting(JobSubmit jobSubmit)
        {
            var result = await _jobManager.CreateJobPosting(jobSubmit, CurrentUserId);

            if (result.Succeeded)
            {
                return(Ok(result));
            }
            else
            {
                return(BadRequest(result));
            }
        }
Ejemplo n.º 3
0
        public async Task <GeneralResponse> CreateJobPosting(JobSubmit jobSubmit, int currentUserId)
        {
            var userRole = await _userManager.GetRolesAsync(await _userManager.FindByIdAsync(currentUserId.ToString()));

            var response = new GeneralResponse();

            if (jobSubmit.Id != currentUserId && !userRole.Contains(RoleConstants.ADMIN))
            {
                return(response.ErrorHandling(ErrorConstants.UnauthorizedAccess, _logger, jobSubmit.Id, currentUserId));
            }
            var company = new Client();

            company = GetById <Client>(jobSubmit.Id);

            var jobPost = new JobPosting()
            {
                Client = company,
            };

            jobPost = _mapper.Map(jobSubmit, jobPost);
            bool dateFromParse    = DateTime.TryParse(jobSubmit.DateFrom, out DateTime dateFrom);
            bool dateToParse      = DateTime.TryParse(jobSubmit.DateTo, out DateTime dateTo);
            bool educationParse   = Enum.TryParse(jobSubmit.Education, out EducationType education);
            bool empCategoryParse = Enum.TryParse(jobSubmit.EmpCategory, out JobType empCategory);

            if (!dateFromParse || !dateToParse || !educationParse || !empCategoryParse || dateFrom > dateTo)
            {
                return(response.ErrorHandling(ErrorConstants.InvalidInput, _logger, dateFrom, dateTo, education, empCategory));
            }

            jobPost.DateFrom    = dateFrom;
            jobPost.DateTo      = dateTo;
            jobPost.EmpCategory = empCategory;
            jobPost.Education   = education;
            if (userRole.Contains(RoleConstants.CLIENT))
            {
                jobPost.Status = JobPostingStatus.Pending;
                Create(jobPost, company.User.FirstName);
            }
            else
            {
                jobPost.Status = JobPostingStatus.Approved;
                Create(jobPost, RoleConstants.ADMIN);
            }

            response.Succeeded = true;
            return(response);
        }
Ejemplo n.º 4
0
        public async Task <JobStatus> SubmitJob(JobSubmit jobSubmit, Dictionary <string, Dictionary <string, string> > originalAttributes)
        {
            var attributes = new JObject();

            foreach (var selectedAcquirerId in jobSubmit.SelectedAcquirersIdentifiers)
            {
                var acquirerAttributes = originalAttributes.ContainsKey(selectedAcquirerId)
                    ? originalAttributes[selectedAcquirerId]
                    : new Dictionary <string, string>();

                AddDefaultTwitterCredentialsIfNotSet(acquirerAttributes);
                AddDefaultRedditCredentialsIfNotSet(acquirerAttributes);

                attributes.Add(selectedAcquirerId, new JObject(
                                   acquirerAttributes.ToList()
                                   .Where(attribute => !string.IsNullOrEmpty(attribute.Key))
                                   .Select(attribute => new JProperty(attribute.Key, attribute.Value)).ToList())
                               );
            }


            jobSubmit.Attributes = attributes;
            return(await _httpService.Post <JobStatus>($"api/job/submit", jobSubmit));
        }
Ejemplo n.º 5
0
 public IEnumerable <JobPosting> CreateJobPosting(JobSubmit jobSubmit)
 {
     return(null);
 }
Ejemplo n.º 6
0
 public ActionResult <IEnumerable <JobPosting> > CreateJobPosting(JobSubmit jobSubmit)
 {
     return(null);
 }