Esempio n. 1
0
        public async Task <IActionResult> GetJobsInDemandByRandomCountries()
        {
            var countries = await _repository.GetAllCountries();

            if (countries == null)
            {
                return(NotFound());
            }

            var randomCountries = countries.OrderBy(x => new Random().Next()).Take(2).ToList();
            var jobsInDemands   = await _repository.GetJobsInDemandByCountryIds(randomCountries);

            if (jobsInDemands == null)
            {
                return(NotFound());
            }

            var jobsInDemandVM = new List <JobsInDemandVM>();

            foreach (var rc in randomCountries)
            {
                jobsInDemandVM.Add(new JobsInDemandVM
                {
                    CountryKR = rc.NameKR,
                    Details   = GetDetails(jobsInDemands
                                           .Where(x => x.CountryId == rc.CountryId)
                                           .OrderBy(x => x.TitleKR)
                                           .ToList())
                });
            }

            return(new OkObjectResult(jobsInDemandVM));
        }