Exemplo n.º 1
0
 public void SaveChanges()
 {
     using (var container = new DomainModelContainer())
     {
         var product1 = new Product
         {
             Name = "Item 1"
         };
         var product2 = new Product
         {
             Name = "Item 2"
         };
         var customer = new Customer
         {
             FirstName = "Elton",
             LastName  = "Stoneman"
         };
         var order = new Order
         {
             Reference = Guid.NewGuid().ToString(),
             Customer  = customer
         };
         order.Products.Add(product1);
         order.Products.Add(product2);
         container.Orders.Add(order);
         container.Save();
     }
 }
Exemplo n.º 2
0
 public void UpdateProduct()
 {
     using (var container = new DomainModelContainer())
     {
         var product = container.Products.First();
         product.Name += " - new!";
         container.Save();
     }
 }
Exemplo n.º 3
0
 public void UpdateOrder()
 {
     using (var container = new DomainModelContainer())
     {
         var order = container.Orders.First();
         order.Reference += ".1";
         container.Save();
     }
 }
Exemplo n.º 4
0
        // POST api/customers
        public HttpResponseMessage Post([FromBody] Customer customer)
        {
            using (var container = new DomainModelContainer())
            {
                container.Customers.Add(customer);
                container.Save();
            }
            var response = new HttpResponseMessage(HttpStatusCode.Created);

            return(response);
        }