public async Task APIJobsBuilder(Developer developer, ApplicationDbContext _context)
        {
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(developer.url);

            string jsonResult = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                List <APIJobSearchIncoming> jobSearch = JsonConvert.DeserializeObject <List <APIJobSearchIncoming> >(jsonResult);
                APIJobSearchSaved           savedJobs = new APIJobSearchSaved();
                int i = 0;
                foreach (var item in jobSearch)
                {
                    savedJobs.id           = _context.ApiJobs.Count() + 1.ToString(); // this does work but it does not operate like you would expect. --- N.E.T. --
                    savedJobs.company      = jobSearch[i].company;
                    savedJobs.company_logo = jobSearch[i].company_logo;
                    savedJobs.company_url  = jobSearch[i].company_url;
                    savedJobs.created_at   = jobSearch[i].created_at;
                    savedJobs.description  = jobSearch[i].description;
                    savedJobs.how_to_apply = jobSearch[i].how_to_apply;
                    savedJobs.location     = jobSearch[i].location;
                    savedJobs.title        = jobSearch[i].title;
                    savedJobs.type         = jobSearch[i].type;
                    i++;

                    dataBaseManager(savedJobs, _context); // stores object in apijobs table --- N.E.T. --
                }
            }
        }
예제 #2
0
        public async Task <IActionResult> PutAPIJobSearchSaved(string id, APIJobSearchSaved aPIJobSearchSaved)
        {
            if (id != aPIJobSearchSaved.id)
            {
                return(BadRequest());
            }

            _context.Entry(aPIJobSearchSaved).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!APIJobSearchSavedExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        public async Task <ActionResult <APIJobSearchSaved> > PostAPIJobSearchSaved(APIJobSearchSaved aPIJobSearchSaved)
        {
            _context.ApiJobs.Add(aPIJobSearchSaved);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (APIJobSearchSavedExists(aPIJobSearchSaved.id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetAPIJobSearchSaved", new { id = aPIJobSearchSaved.id }, aPIJobSearchSaved));
        }
 public void dataBaseManager(APIJobSearchSaved jobToSave, ApplicationDbContext _context)
 {
     _context.ApiJobs.Add(jobToSave);
     _context.SaveChanges();
 }