public async Task<IHttpActionResult> PutAdmin(int id, Admin admin) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != admin.Id) { return BadRequest(); } db.Entry(admin).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdminExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAdmin(Admin admin) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Admins.Add(admin); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = admin.Id }, admin); }