Exemplo n.º 1
0
        public void AddCakeToBill(object parameter)
        {
            var Cake = CakeServices.loadSingleCake(int.Parse(parameter.ToString()));

            Order.AddCake(Cake, 1);
            CakeInOrders = new ObservableCollection <CakeInOrder>(Order.listCakes);
            OnPropertyChanged(nameof(CakeInOrders));
            TotalPrice = Order.CalculateSum();
        }
        public UpdateCakePageViewModel(int CakeID, MainViewModel param)
        {
            this.mainViewModel = param;
            AllCategory        = new ObservableCollection <CategoryModel>();
            List <CategoryModel> tempList = new List <CategoryModel>();

            tempList = categoryServices.LoadAll();
            for (int i = 0; i < tempList.Count(); i++)
            {
                AllCategory.Add(tempList[i]);
            }
            addImageButtonCommand = new RelayCommand(o => updateImageButtonClick());
            doneButtonCommand     = new RelayCommand(o => doneButtonClick(CakeID, param));
            CakeModel myCake = new CakeModel();

            myCake       = cakeServices.loadSingleCake(CakeID);
            Name         = myCake.Name;
            ImportPrice  = myCake.ImportPrice;
            SellingPrice = myCake.SellingPrice;
            Amount       = 0;
            Information  = myCake.Information;
            Unit         = myCake.Unit;
            OldAmount    = myCake.Amount;
            for (int i = 0; i < AllCategory.Count(); i++)
            {
                if (AllCategory[i].Name == myCake.Category.Name)
                {
                    CategoryID = i;
                }
            }
            //Image
            var directory = AppDomain.CurrentDomain.BaseDirectory;

            directory  += "Database\\Images\\CakeImages\\";
            ImageSource = directory + myCake.ID + ".png";
            OnPropertyChanged(nameof(Name));
            OnPropertyChanged(nameof(ImportPrice));
            OnPropertyChanged(nameof(SellingPrice));
            OnPropertyChanged(nameof(Amount));
            OnPropertyChanged(nameof(Information));
            OnPropertyChanged(nameof(Unit));
            OnPropertyChanged(nameof(ImageSource));
        }
Exemplo n.º 3
0
        public CakeInOrder AddCake(CakeModel cake, int numberOfCake)
        {
            CakeInOrder cakeInOrder = new CakeInOrder
            {
                CakeID    = cake.ID,
                SellPrice = cake.SellingPrice,
                Amount    = numberOfCake,
                cake      = _cakeServices.loadSingleCake(cake.ID)
            };

            int check = CheckExistedCake(cakeInOrder.CakeID);

            if (check == -1)
            {
                listCakes.Add(cakeInOrder);
            }
            else
            {
                listCakes[check].Amount++;
            }


            return(cakeInOrder);
        }
Exemplo n.º 4
0
 public CakeDetailPageViewModel(int cakeID)
 {
     Cake  = CakeServices.loadSingleCake(cakeID);
     Title = Cake.Name;
 }