public async Task <IActionResult> PutCandidatureSpont(int id, CandidatureSpont candidatureSpont) { if (id != candidatureSpont.Id) { return(BadRequest()); } _context.Entry(candidatureSpont).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CandidatureSpontExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <CandidatureSpont> > PostCandidatureSpont(CandidatureSpont candidatureSpont) { _context.CandidatureSpont.Add(candidatureSpont); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCandidatureSpont", new { id = candidatureSpont.Id }, candidatureSpont)); }
public async Task <CandidatureSpont> GetCandidatureSpont(int Id) { _oCandidatureSpont = new CandidatureSpont(); using (var httpClient = new HttpClient(_clientHandler)) { using (var response = await httpClient.GetAsync("https://localhost:44304/api/CandidatureSponts/" + Id)) { string apiResponse = await response.Content.ReadAsStringAsync(); _oCandidatureSpont = JsonConvert.DeserializeObject <CandidatureSpont>(apiResponse); } } return(_oCandidatureSpont); }
public async Task <CandidatureSpont> PostCandidatureSpont(CandidatureSpont CandidatureSpont) { _oCandidatureSpont = new CandidatureSpont(); using (var httpClient = new HttpClient(_clientHandler)) { StringContent content = new StringContent(JsonConvert.SerializeObject(CandidatureSpont), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync("https://localhost:44304/api/CandidatureSponts", content)) { string apiResponse = await response.Content.ReadAsStringAsync(); _oCandidatureSpont = JsonConvert.DeserializeObject <CandidatureSpont>(apiResponse); } } return(_oCandidatureSpont); }
public async Task <IActionResult> PutCandidatureSpont(int Id, CandidatureSpont CandidatureSpont) { _oCandidatureSpont = new CandidatureSpont(); using (var httpClient = new HttpClient(_clientHandler)) { StringContent content = new StringContent(JsonConvert.SerializeObject(CandidatureSpont), Encoding.UTF8, "application/json"); using (var response = await httpClient.PutAsync("https://localhost:44304/api/CandidatureSponts/" + Id, content)) { string apiResponse = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { _oCandidatureSpont = JsonConvert.DeserializeObject <CandidatureSpont>(apiResponse); return(Ok(_oCandidatureSpont)); } else { return(BadRequest()); } } } }