public IHttpActionResult PutCustomerInfo(int id, CustomerInfo customerInfo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != customerInfo.CustomerId) { return BadRequest(); } db.Entry(customerInfo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerInfoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCustomerInfo(CustomerInfo customerInfo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } customerInfo.RegistrationDate = DateTime.Now; db.CustomerInfoes.Add(customerInfo); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = customerInfo.CustomerId }, customerInfo); }