//insert customer public HttpResponseMessage Post(CustomerModel customer) { if (ModelState.IsValid) { db.AddCustomer(customer); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, customer); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = customer.Id })); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
//update customer public HttpResponseMessage Put(int id, CustomerModel customer) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } if (id != customer.Id) { return Request.CreateResponse(HttpStatusCode.BadRequest); } try { db.EditCustomer(customer); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }
public string EditCustomer(CustomerModel customer) { return ""; }
public string AddCustomer(CustomerModel customer) { return null; }