public bool SaveDish(int id_dish, string name_dish, int?id_selection, bool availability, string price1, string price2)    //сохранение изменений
        {
            decimal rub  = decimal.Parse(price1);
            decimal kop  = decimal.Parse(price2) * decimal.Parse((0.01).ToString());
            var     dish = db.list_of_dishes.FirstOrDefault(w => w.id_dish == id_dish);

            if ((name_dish != "") && (price != 0) && (id_selection != null))
            {
                if (dish == null)
                {
                    dish         = new list_of_dishes();
                    dish.id_dish = id_dish;
                }
                dish.name_dish    = employee.Savestring(name_dish);
                dish.id_selection = id_selection;
                dish.availability = availability;
                dish.price        = rub + kop;
                db.list_of_dishes.AddOrUpdate(dish);
                db.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 public bool DeleteStock(int id)    //возврат акции, информацию о которой необходимо удалить
 {
     try
     {
         var emp = db.stocks.First(w => w.id_stock == id);
         db.stocks.Remove(emp);
         db.SaveChanges();
         return(true);
     }
     catch { return(false); }
 }
 public bool DeleteEmp(int id, employee empl)    //возврат сотрудника, информацию о котором необходимо удалить
 {
     try
     {
         if (id != empl.id_employee)
         {
             var emp = db.employee.First(w => w.id_employee == id);
             db.employee.Remove(emp);
             db.SaveChanges();
         }
         return(true);
     }
     catch { return(false); }
 }
        public int SaveOrd(int id_emp, int id_tab)    //сохранение информации о заказе
        {
            orders ord = new orders();

            ord.id_employee = db.employee.First(p => p.id_employee == id_emp).id_employee;
            ord.id_table    = id_tab;
            ord.time_order  = DateTime.Now.TimeOfDay;
            var stock = new List <stocks>();

            if (db.stocks.Where(p => p.start_time < p.end_time) != null)
            {
                stock = db.stocks.Where(p => p.start_time <= ord.time_order && p.end_time >= ord.time_order).ToList();
            }
            if (db.stocks.Where(p => p.start_time > p.end_time) != null)
            {
                stock.AddRange(db.stocks.Where(p => (p.start_time > p.end_time) && ((p.start_time >= ord.time_order) || (p.end_time >= ord.time_order))).ToList());
            }
            if (stock.Count != 0)
            {
                var discount = stock.Min(p => p.discount);
                ord.id_stock = db.stocks.First(p => p.discount == discount).id_stock;
            }
            else
            {
                ord.id_stock = null;
            }
            db.orders.Add(ord);
            db.SaveChanges();
            foreach (content_orders i in ListDishesinOrd)
            {
                var content = new content_orders();
                content.id_content_order = i.id_content_order;
                content.id_order         = ord.id_order;
                content.id_dish          = db.list_of_dishes.First(p => p.id_dish == i.id_dish).id_dish;
                content.count_dish       = i.count_dish;
                db.content_orders.Add(content);
                db.SaveChanges();
            }
            return(ord.id_order);
        }
Beispiel #5
0
        public void EditContOrd(int id_cont, int count)             //изменение конечного списка заказа (в случае возврата блюда)
        {
            var edit = db.content_orders.First(p => p.id_content_order == id_cont);

            if (count != 0)
            {
                edit.count_dish = count;
                db.content_orders.AddOrUpdate(edit);
            }
            else
            {
                db.content_orders.Remove(edit);
            }
            db.SaveChanges();
        }