public IHttpActionResult PostJusCustomer(JusCustomer jusCustomer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.JusCustomers.Add(jusCustomer); try { db.SaveChanges(); } catch (DbUpdateException) { if (JusCustomerExists(jusCustomer.OwnerID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = jusCustomer.OwnerID }, jusCustomer)); }
public IHttpActionResult PutJusCustomer(int id, JusCustomer jusCustomer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != jusCustomer.OwnerID) { return(BadRequest()); } db.Entry(jusCustomer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!JusCustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetJusCustomer(int id) { JusCustomer jusCustomer = db.JusCustomers.Find(id); if (jusCustomer == null) { return(NotFound()); } return(Ok(jusCustomer)); }
public IHttpActionResult DeleteJusCustomer(int id) { JusCustomer jusCustomer = db.JusCustomers.Find(id); if (jusCustomer == null) { return(NotFound()); } db.JusCustomers.Remove(jusCustomer); db.SaveChanges(); return(Ok(jusCustomer)); }