Beispiel #1
0
        public async Task <ActionResult> Update_Employers(int id, EmployersDTO employer)
        {
            if (id != employer.Employer_id || !EmployerExists(id))
            {
                return(BadRequest());
            }
            else
            {
                var employer_profile = _context.Employers_Description.SingleOrDefault(x => x.Employers_id == id);
                employer_profile.Rating = employer.Rating;
                await _context.SaveChangesAsync();

                return(NoContent());
            }
        }
Beispiel #2
0
        public async Task <ActionResult> Update_Employers(int id, EmployersDTO employer)
        {
            if (id != employer.Employer_id || !EmployerExists(id))
            {
                return(BadRequest());
            }
            else
            {
                var employers        = _context.Employers.SingleOrDefault(x => x.id == id);
                var employer_profile = _context.Employers_Description.SingleOrDefault(x => x.Employers_id == id);
                employers.id             = employer_profile.Employers_id;
                employers.Name           = employer.Name;
                employers.Entreprise     = employer.Entreprise;
                employer_profile.Age     = employer.Age;
                employer_profile.Job     = employer.Job;
                employer_profile.Country = employer.Country;
                await _context.SaveChangesAsync();

                return(NoContent());
            }
        }
Beispiel #3
0
        public ActionResult <EmployersDTO> GetEmployer_byId(int id)
        {
            EmployersDTO theEmployer = new EmployersDTO();

            theEmployer.Employer_id = id;
            bool check = true;

            foreach (var s in _context.Employers.ToList())
            {
                if (s.id == id)
                {
                    theEmployer.Name       = s.Name;
                    theEmployer.Entreprise = s.Entreprise;
                    theEmployer.User_id    = s.user_id;
                    check = false;
                }
            }
            if (check)
            {
                return(NotFound());
            }
            foreach (var detail in _context.Employers_Description.ToList())
            {
                if (detail.Employers_id == id)
                {
                    theEmployer.Age     = detail.Age;
                    theEmployer.Job     = detail.Job;
                    theEmployer.Country = detail.Country;
                    theEmployer.Rating  = detail.Rating;
                }
            }
            List <JobDTO> jobList = new List <JobDTO>();

            foreach (var job in _context.Jobs_list.ToList())
            {
                if (job.Employers_id == id)
                {
                    JobDTO newJob = new JobDTO();
                    foreach (var jobname in _context.Jobs.ToList())
                    {
                        if (job.Jobs_id == jobname.id)
                        {
                            newJob.Name = jobname.Name;
                        }
                    }
                    foreach (var jobdesciption in _context.Jobs_Description.ToList())
                    {
                        if (job.Jobs_id == jobdesciption.jobs_id)
                        {
                            newJob.Salary          = jobdesciption.Salary;
                            newJob.Skills_required = jobdesciption.Skills_required;
                        }
                    }
                    foreach (var jobenterprise in _context.Employers.ToList())
                    {
                        if (jobenterprise.id == job.Employers_id)
                        {
                            newJob.Entreprise = jobenterprise.Entreprise;
                        }
                    }
                    jobList.Add(newJob);
                }
            }
            theEmployer.Jobs = jobList;
            return(theEmployer);
        }