public async Task <IActionResult> PutUsers(int id, Users users) { if (id != users.Id) { return(BadRequest()); } _context.Entry(users).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Customer> > PostCustomer(Customer customer) { _context.Customer.Add(customer); await _context.SaveChangesAsync(); var response = CreatedAtAction("GetCustomer", new { id = customer.CustomerId }, customer); CacheUpdate(); return(response); }
//Añade el token al usuario en la bbdd private async Task <bool> AnadirTokenAsync(string token) { persistUser.Token = token; _context.Entry(persistUser).State = EntityState.Modified; try { var result = await _context.SaveChangesAsync(); return(result > 0); } catch (DbUpdateConcurrencyException) { return(false); } }