Esempio n. 1
0
 // DELETE api/<controller>/5
 public void Delete(string id)
 {
     CustomerContext customersdb = new CustomerContext();
     Customer cust=customersdb.Customers.Find(id);
     customersdb.Customers.Remove(cust);
     customersdb.SaveChanges();
 }
Esempio n. 2
0
        // PUT api/<controller>/5
        public void Put(int id, [FromBody]Customer customer)
        {
            CustomerContext customersdb = new CustomerContext();
            Customer customerToRemove=customersdb.Customers.Find(customer.id);

            customersdb.Customers.Remove(customerToRemove);
            Customer updatedCustomer = customer;
            customersdb.Customers.Add(updatedCustomer);

            customersdb.SaveChanges();
        }
Esempio n. 3
0
 // POST api/<controller>
 public void Post([FromBody]Customer customer)
 {
     CustomerContext customersdb = new CustomerContext();
     customersdb.Customers.Add(customer);
     customersdb.SaveChanges();
 }
Esempio n. 4
0
 // GET api/<controller>
 public IEnumerable<Customer> Get()
 {
     CustomerContext customersdb = new CustomerContext();
     return customersdb.Customers;
 }