Beispiel #1
0
        public async Task <ActionResult> Update_Seekers(int id, SeekersDTO seek)
        {
            if (id != seek.Seekers_id || !SeekersExists(id))
            {
                return(BadRequest());
            }
            else
            {
                var seeks        = _context.Seekers.SingleOrDefault(x => x.id == id);
                var seek_profile = _context.Seekers_Description.SingleOrDefault(x => x.Seekers_id == id);
                seek_profile.Rating = seek.Rating;
                await _context.SaveChangesAsync();

                return(NoContent());
            }
        }
        public async Task <ActionResult> Update_Seekers(int id, SeekersDTO seek)
        {
            if (id != seek.Seekers_id || !SeekersExists(id))
            {
                return(BadRequest());
            }
            else
            {
                var seeks        = _context.Seekers.SingleOrDefault(x => x.id == id);
                var seek_profile = _context.Seekers_Description.SingleOrDefault(x => x.Seekers_id == id);
                seeks.id              = seek_profile.Seekers_id;
                seeks.Name            = seek.Name;
                seek_profile.Age      = seek.Age;
                seek_profile.Jobs_exp = seek.Jobs_exp;
                seek_profile.Adress   = seek.Adress;
                seek_profile.Skills   = seek.Skills;
                await _context.SaveChangesAsync();

                return(NoContent());
            }
        }
        public ActionResult <SeekersDTO> GetSeekers_byId(int id)
        {
            SeekersDTO TheSeekers = new SeekersDTO();

            TheSeekers.Seekers_id = id;
            bool check = true;

            foreach (var s in _context.Seekers)
            {
                if (s.id == id)
                {
                    TheSeekers.Name    = s.Name;
                    TheSeekers.user_id = s.user_id;
                    check = false;
                }
            }
            if (check)
            {
                return(NotFound());
            }
            foreach (Seekers_Description Seek_Des in _context.Seekers_Description)
            {
                if (Seek_Des.Seekers_id == id)
                {
                    TheSeekers.Age      = Seek_Des.Age;
                    TheSeekers.Adress   = Seek_Des.Adress;
                    TheSeekers.Jobs_exp = Seek_Des.Jobs_exp;
                    TheSeekers.Skills   = Seek_Des.Skills;
                    TheSeekers.Rating   = Seek_Des.Rating;
                }
            }
            List <JobDTO> jobList = new List <JobDTO>();

            foreach (var job in _context.Jobs_list.ToList())
            {
                if (job.Seekers_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);
                }
            }
            TheSeekers.Jobs = jobList;

            return(TheSeekers);
        }