public BargainDish CreateBargainDish(BargainDishBean bean)
        {
            BargainDish beanBack = new BargainDish();
            beanBack.Id = bean.Id;
            beanBack.DishId = bean.DishId;
            beanBack.StartTime = bean.StartTime;
            beanBack.EndTime = bean.EndTime;
            beanBack.StartDate = bean.StartDate;
            beanBack.EndDate = bean.EndDate;
            beanBack.Week1 = bean.Week1;
            beanBack.Week2 = bean.Week2;
            beanBack.Week3 = bean.Week3;
            beanBack.Week4 = bean.Week4;
            beanBack.Week5 = bean.Week5;
            beanBack.Week6 = bean.Week6;
            beanBack.Week0 = bean.Week0;
            beanBack.MarketTypeId = bean.MarketTypeId;
            beanBack.Enable = bean.Enable;
            beanBack.CreateBy = bean.CreateBy;
            beanBack.CreateTime = DateTime.Now;
            beanBack.Update_by = bean.UpdateBy;
            beanBack.UpdateTime = bean.UpdateDatetime;
            beanBack.Deleted = bean.Deleted;
            return beanBack;

        }
        public List<BargainDish> BatchSaveBargainDish(BargainDish[] DBDishes)
        {
            if (DBDishes != null && DBDishes.Length > 0) {
                List<BargainDish> list = new List<BargainDish>();
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    foreach (var element in DBDishes) {
                        
                        entities.BargainDish.Add(element);
                        entities.SaveChanges();
                        //foreach (var elem in element.BargainDishPrice) { 
                        //    elem.BargainDishId = element.Id;
                        //    entities.BargainDishPrice.Add(elem);
                        //    entities.SaveChanges();
                        //}
                        list.Add(element);
                    }
                    return list;
                }
            }

            return null;
        }
        public BargainDishBean CreateBargainDishBean(BargainDish bean)
        {
            this.Id = bean.Id;
            this.DishId = bean.DishId;
            this.StartTime = bean.StartTime;
            this.EndTime = bean.EndTime;
            this.StartDate = bean.StartDate;
            this.EndDate = bean.EndDate;
            this.Week1 = bean.Week1;
            this.Week2 = bean.Week2;
            this.Week3 = bean.Week3;
            this.Week4 = bean.Week4;
            this.Week5 = bean.Week5;
            this.Week6 = bean.Week6;
            this.Week0 = bean.Week0;
            this.MarketTypeId = bean.MarketTypeId;
            this.Enable = bean.Enable;
            this.CreateBy = bean.CreateBy;
            this.CreateDatetime = bean.CreateTime;
            this.UpdateBy = bean.Update_by;
            this.UpdateDatetime = bean.UpdateTime;
            this.Deleted = bean.Deleted;
            this.BargainDishPrice = bean.BargainDishPrice;
            InjectDish(bean.Dish);
            InjectBargainDishPrice();
            return this;

        }
 //修改 特价菜信息
 public bool UpdateBargainDish(BargainDish BDish)
 {
     if (BDish == null) {
         return false;
     }
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         var  type  = entities.BargainDish.SingleOrDefault(bt=>bt.Id==BDish.Id);
         if (type != null) {
             type.StartDate = BDish.StartDate;
             type.EndDate = BDish.EndDate;
             type.StartTime = BDish.StartTime;
             type.EndTime = BDish.EndTime;
             type.Week1 = BDish.Week1;
             type.Week2 = BDish.Week2;
             type.Week3 = BDish.Week3;
             type.Week4 = BDish.Week4;
             type.Week5 = BDish.Week5;
             type.Week6 = BDish.Week6;
             type.Week0 = BDish.Week0;
             type.MarketTypeId = BDish.MarketTypeId;
             entities.SaveChanges();
             BargainDishPrice bdp = BDish.BargainDishPrice.First();
             int priceId = bdp.Id;
             if (priceId != 0)
             {
                 var typeprice = entities.BargainDishPrice.SingleOrDefault(bt => bt.Id == priceId);
                 if (typeprice != null) {
                     typeprice.Price1 = bdp.Price1;
                     typeprice.Price2 = bdp.Price2;
                     typeprice.Price3 = bdp.Price3;
                     typeprice.MemberPrice3 = bdp.MemberPrice3;
                     typeprice.MemberPrice2 = bdp.MemberPrice2;
                     typeprice.MemberPrice1 = bdp.MemberPrice1;
                     entities.SaveChanges();
                     return true;
                 }
             }
         }
     }
     return false;
 }