Ejemplo n.º 1
0
        // Retrieve order item in database
        public OrderItem(ChiTietDonhang ChiTiet)
        {
            this.ID = ChiTiet.ID;

            this._Item = new Drink(ChiTiet.MonAn);
            //MessageBox.Show(_Item.Price + "-");
            this.Number = (int)ChiTiet.SOLUONG;
            //this.Note
            this.Discount = ChiTiet.GIAMGIA;
            if (HasToppings(ChiTiet))
            {
                // TODO: need refactor
                List <OrderItem> Option = ChiTiet.ChiTietDonhang1.Where(x => OrderService.IsTopping(x.MonAn.LoaiMonAn)).Select(x => new OrderItem(x)).ToList();
                this.ToppingsOfItem = new ObservableCollection <OrderItem>(Option);
                this.Parent         = null;
            }
            else
            {
                ToppingsOfItem = null;
                //Parent = ...
            }
            //if (HasOptions(ChiTiet))
            //{
            //    // TODO: need refactor
            //    List<OrderItem> Option = ChiTiet.ChiTietDonhang1.Where(x => OrderService.IsOption(x.MonAn.LoaiMonAn)).Select(x => new OrderItem(x)).ToList();
            //    this.OptionsOfItem = new ObservableCollection<OrderItem>(Option);
            //    this.Parent = null;
            //}
            //else
            //{
            //    OptionsOfItem = null;
            //    //Parent = ...
            //}
        }
Ejemplo n.º 2
0
 public bool themChiTietDonHang(ChiTietDonhang CTDonHang)
 {
     if (!tonTaiDonHang(CTDonHang.MADH))
     {
         return(false);
     }
     else
     {
         CTDonHang.CREADTEDAT = DateTime.Now;
         DataProvider.ISCreated.DB.ChiTietDonhangs.Add(CTDonHang);
         DataProvider.ISCreated.DB.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 3
0
        // Save order item, if it is topping or option, reference to Parent ID
        public ChiTietDonhang ToChiTietDonHang(int OrderID, DateTime Now)
        {
            if (this.Parent != null)
            {
                this.Number = this.Parent.Number;
            }
            ChiTietDonhang result = new ChiTietDonhang()
            {
                ID         = this.ID,
                MAMON      = this.Item.ID,
                MADH       = OrderID,
                SOLUONG    = this.Number,
                DONGIA     = this.Price,
                THANHTIEN  = this.Price * this.Number - this.Discount,
                ISDEL      = 0,
                CREADTEDAT = Now,
                UPDATEDAT  = Now,
                PARENTID   = (this.Parent == null) ? (int?)null : this.Parent.ID,
                PARENTMADH = (this.Parent == null) ? (int?)null : OrderID
            };

            return(result);
        }
Ejemplo n.º 4
0
 private static bool IsDrink(ChiTietDonhang chiTietDonhang)
 {
     return(chiTietDonhang.ChiTietDonhang2 == null);
 }
Ejemplo n.º 5
0
        //public bool HasOptions()
        //{
        //    return (OptionsOfItem.Count > 0);
        //}

        private bool HasToppings(ChiTietDonhang chiTietDonhang)
        {
            return(chiTietDonhang.ChiTietDonhang1.Count > 0);
        }