public async Task <IActionResult> PutCityInfo(int id, CityInfo cityInfo) { if (id != cityInfo.Id) { return(BadRequest()); } _context.Entry(cityInfo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CityInfoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutCliente(int id, Cliente cliente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cliente.ClienteId) { return(BadRequest()); } db.Entry(cliente).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutSubjects(int id, Subjects subjects) { if (id != subjects.id) { return(BadRequest()); } _context.Entry(subjects).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubjectsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutUser(int id, User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != user.UserId) { return(BadRequest()); } if (user.Password == null) { User _user = db.Users.Find(id); user.Password = _user.Password; } var local = db.Set <User>() .Local .FirstOrDefault(f => f.UserId == id); if (local != null) { db.Entry(local).State = EntityState.Detached; } db.Entry(user).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }