public static void AddOrder(int customer, IOrderList order)
 {
     using (var context = new PZeroContext())
     {
         decimal price = 0;
         foreach (var orderdata in order.Cart)
         {
             price += orderdata.Price * orderdata.Quantity;
         }
         var ticket = new Orders
         {
             CustId    = customer,
             Total     = price,
             Stamp     = DateTime.Now,
             OrderData = order.Cart
         };
         foreach (var orderdata in order.Cart)
         {
             context.Products.Find(orderdata.PrdId).Stock -= orderdata.Quantity;
             orderdata.OrdId = ticket.OrdId;
         }
         context.Add(ticket);
         context.SaveChanges();
     }
 }
 public static void AddCustomer(string name)
 {
     using (var context = new PZeroContext())
     {
         var customer = new Customers {
             Name = name
         };
         context.Add(customer);
         context.SaveChanges();
     }
 }
 public static void AddLocation(string name)
 {
     using (var context = new PZeroContext())
     {
         var location = new Locations {
             Name = name
         };
         context.Add(location);
         context.SaveChanges();
     }
 }
 public static void AddProduct(string name, int LocID, decimal p, int s = -1)
 {
     using (var context = new PZeroContext())
     {
         var product = new Products
         {
             Name  = name,
             Loc   = context.Locations.Find(LocID),
             Price = p,
             Stock = s
         };
         context.Add(product);
         context.SaveChanges();
     }
 }