Пример #1
0
        static public IEnumerable <@event> GetEventsByCustomerName(string name, string surname)
        {
            using (DataClasses1DataContext context = new DataClasses1DataContext())
            {
                customer customer = CustomerCRUD.GetCustomerByNames(name, surname);

                List <@event> events = new List <@event>();
                foreach (@event eveent in [email protected]())
                {
                    if (eveent.customer == customer.customer_id)
                    {
                        events.Add(eveent);
                    }
                }
                return(events);
            }
        }
Пример #2
0
 static public bool BuyDonut(int id, int d, int c, int amount)
 {
     using (DataClasses1DataContext context = new DataClasses1DataContext())
     {
         if (donutCRUD.GetDonut(d) != null && c != null)
         {
             if (donutCRUD.GetDonut(d).quantity > 0 && donutCRUD.GetDonut(d).quantity > amount)
             {
                 addEvent(id, DateTime.Today, false, amount, donutCRUD.GetDonut(d).donut_id, CustomerCRUD.GetCustomer(c).customer_id);
                 donutCRUD.GetDonut(d).quantity = donutCRUD.GetDonut(d).quantity - amount;
                 donutCRUD.updateQuantity(donutCRUD.GetDonut(d).donut_id, donutCRUD.GetDonut(d).quantity);
                 return(true);
             }
         }
     }
     return(false);
 }