public async Task <IHttpActionResult> PutTenUser(int id, TenUser tenUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tenUser.UserIndex) { return(BadRequest()); } db.Entry(tenUser).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TenUserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void ChangeUserProfile(int id, string profileUrl) { TenUserDbContext udb = new TenUserDbContext(); TenUser tenuser = udb.TenUsers.Find(id); tenuser.ProfileUrl = profileUrl; udb.Entry(tenuser).State = EntityState.Modified; udb.SaveChanges(); }
public async Task <IHttpActionResult> GetTenUser(int id) { TenUser tenUser = await db.TenUsers.FindAsync(id); if (tenUser == null) { return(NotFound()); } return(Ok(tenUser)); }
public async Task <IHttpActionResult> PostTenUser(TenUser tenUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TenUsers.Add(tenUser); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = tenUser.UserIndex }, tenUser)); }
public async Task <IHttpActionResult> DeleteTenUser(int id) { TenUser tenUser = await db.TenUsers.FindAsync(id); if (tenUser == null) { return(NotFound()); } db.TenUsers.Remove(tenUser); await db.SaveChangesAsync(); return(Ok(tenUser)); }