public async Task <ActionResult <ContactoAPI> > PostContactoAPI(ContactoAPI contactoAPI) { _context.ContactoAPIs.Add(contactoAPI); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetContactoAPI), new { id = contactoAPI.Id }, contactoAPI)); }
public async Task <IActionResult> PutContactoAPI(int id, ContactoAPI contactoAPI) { if (id != contactoAPI.Id) { return(BadRequest()); } _context.Entry(contactoAPI).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactoAPIExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task Update(string id, string firstname, string lastname, string phoneNumber, string email) { ContactoAPI contact = new ContactoAPI() { Id = id, firstname = firstname, lastname = lastname, phoneNumber = phoneNumber, email = email }; System.Diagnostics.Debug.Write(id + " HOLA MUNDO"); HttpClient cliente = await Detalle.getConection(); await cliente.PutAsync(Detalle.url + "/" + id, new StringContent(JsonConvert.SerializeObject(contact), Encoding.UTF8, "application/json")); }
public async Task <ContactoAPI> Post(string id, string firstname, string lastname, string phoneNumber, string email) { ContactoAPI contact = new ContactoAPI() { Id = "", firstname = firstname, lastname = lastname, phoneNumber = phoneNumber, email = email }; HttpClient cliente = await Detalle.getConection(); var response = await cliente.PostAsync(Detalle.url, new StringContent(JsonConvert.SerializeObject(contact), Encoding.UTF8, "application/json")); return(JsonConvert.DeserializeObject <ContactoAPI>(await response.Content.ReadAsStringAsync())); }