public IHttpActionResult Delete(int id)
 {
     if (id < 0)
     {
         return(BadRequest("Invalid customer id"));
     }
     using (var ctx = new CRUD_SampleEntities())
     {
         var existingCustomer = ctx.Customers.Where(c => c.Id == id).FirstOrDefault();
         if (existingCustomer == null)
         {
             return(NotFound());
         }
         ctx.Entry(existingCustomer).State = System.Data.Entity.EntityState.Deleted;
         ctx.SaveChanges();
     }
     return(Ok());
 }
 public IHttpActionResult Put(CustomerDTO customer)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Invalid data"));
     }
     using (var ctx = new CRUD_SampleEntities())
     {
         var existingCustomer = ctx.Customers.Where(c => c.Id == customer.Id).FirstOrDefault();
         if (existingCustomer == null)
         {
             return(NotFound());
         }
         existingCustomer.CustName  = customer.CustName;
         existingCustomer.CustEmail = customer.CustEmail;
         ctx.SaveChanges();
     }
     return(Ok());
 }
        public IHttpActionResult PostNewCustomer(CustomerDTO customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data"));
            }
            using (var ctx = new CRUD_SampleEntities())
            {
                ctx.Customers.Add(new Customer()
                {
                    Id        = customer.Id,
                    CustName  = customer.CustName,
                    CustEmail = customer.CustEmail
                });

                ctx.SaveChanges();
            }
            return(Ok());
        }