public bool RemoveCustomer(int customerId)
 {
     if (customerId > 0)
     {
         using (sql36Entities entities = new sql36Entities())
         {
             entities.Customers.Remove(entities.Customers.Where(c => c.Id == customerId).Take(1).FirstOrDefault());
             entities.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
 public bool AddCustomer(Customer customer)
 {
     if (customer != null)
     {
         using (sql36Entities entities = new sql36Entities())
         {
             entities.Customers.Add(customer);
             entities.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
 public bool AddOrder(Order order)
 {
     if (order != null)
     {
         using (sql36Entities entities = new sql36Entities())
         {
             entities.Orders.Add(order);
             entities.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
 public bool RemoveOrder(int orderId)
 {
     using (sql36Entities entities = new sql36Entities())
     {
         if (entities.Orders.Where(o => o.Id == orderId).FirstOrDefault() != null)
         {
             entities.Orders.Remove(entities.Orders.Where(o => o.Id == orderId).Take(1).FirstOrDefault());
             entities.SaveChanges();
             Console.WriteLine("removed successfully!");
             return(true);
         }
         Console.WriteLine("no order with this id was found!");
         return(false);
     }
 }
 public bool UpdateCustomer(int customerId, Customer customer)
 {
     if (customerId > 0 && customer != null)
     {
         using (sql36Entities entities = new sql36Entities())
         {
             var selectedCustomer = entities.Customers.Where(c => c.Id == customerId).Take(1).FirstOrDefault();
             selectedCustomer.Id      = customer.Id;
             selectedCustomer.Name    = customer.Name;
             selectedCustomer.Country = customer.Country;
             selectedCustomer.Age     = customer.Age;
             entities.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
        public bool UpdateOrder(int orderId, Order order)
        {
            using (sql36Entities entities = new sql36Entities())
            {
                if (entities.Orders.Where(o => o.Id == orderId).FirstOrDefault() != null && order != null)
                {
                    var selectedOrder = entities.Orders.Where(o => o.Id == orderId).Take(1).FirstOrDefault();
                    selectedOrder.Id          = order.Id;
                    selectedOrder.Customer_Id = order.Customer_Id;
                    selectedOrder.Price       = order.Price;
                    selectedOrder.Date        = order.Date;
                    entities.SaveChanges();

                    return(true);
                }
                return(false);
            }
        }