Ejemplo n.º 1
0
 //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);
     }
 }
Ejemplo n.º 2
0
 //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);
 }
Ejemplo n.º 3
0
 public string EditCustomer(CustomerModel customer)
 {
     return "";
 }
Ejemplo n.º 4
0
 public string AddCustomer(CustomerModel customer)
 {
     return null;
 }