Esempio n. 1
0
        public async Task <IActionResult> AddPost([FromBody] Jobs model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var postId = await JobsRepository.AddJob(model);

                    if (postId > 0)
                    {
                        return(Ok(postId));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
Esempio n. 2
0
        public void AddJob(Job job)
        {
            var log = new Log(job, "Add");

            _repo.AddJob(job);
            _repo.AddLog(log);
            _repo.SaveChanges();
        }
Esempio n. 3
0
 public async Task <IActionResult> AddUser([FromBody] JobDto job)
 {
     try
     {
         return(Ok(await _jobsRepository.AddJob(_mapper.Map <JobDb>(job))));
     }
     catch (Exception ex)
     {
         return(BadRequest("Bład przy dodawaniu nowego użytkownika" + ex.Message));
     }
 }
Esempio n. 4
0
        public IActionResult AddJob([FromBody] JobsViewModel jobViewModel)
        {
            try
            {
                Job    job    = Mapper.Map <JobsViewModel, Job>(jobViewModel);
                string UserId = IdentityHelper.GetUserId(HttpContext);

                job.IsApproved   = 0;
                job.Expired      = 0;
                job.UserId       = UserId;
                job.CreationDate = DateTime.Now;
                job.LastUpdate   = DateTime.Now;

                // Ensure the job advertisment runs for atleast 7 days unless it is removed
                if (job.Expiry < DateTime.Now.AddDays(7))
                {
                    return(BadRequest());
                }

                // If a companyId is passed, ensure the company exists and the user has access to it
                if (job.CompanyId.HasValue)
                {
                    Company company = _companiesRepository.GetCompanyById_model(job.CompanyId.Value);
                    if (company == null)
                    {
                        return(BadRequest());
                    }
                    else
                    {
                        if (company.UserId != UserId)
                        {
                            return(Unauthorized());
                        }
                    }
                }

                _jobsRespository.AddJob(job);

                string content = "A new job listing has been added\n" +
                                 "\nID: " + job.JobId +
                                 "\nTitle: " + job.JobTitle +
                                 "\n\nPlease go to https://capstone1.azurewebsites.net/admin to approve this job listing";
                string subject = "New job listing";

                _emailService.SendToAdmins(subject, content);
                return(Ok());
            }
            catch (Exception e)
            {
                return(NotFound());
            }
        }
Esempio n. 5
0
 public bool Post(Montaza montaza)
 {
     return(_jobRepository.AddJob(montaza));
 }