Ejemplo n.º 1
0
 public MainViewModel(VendingMachineCore vendingMachine, User user, IUserNotify userNotify)
 {
     this.vendingMachine = vendingMachine;
     this.user = user;
     this.userNotify = userNotify;
     UserViewModel = new UserViewModel(user);
     VendingMachineViewModel=new VendingMachineViewModel(vendingMachine);
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();

                UpdateState();
            }
            else
            {
                vendingMachineCore = (VendingMachineCore)Session["vm"];
                user = (User)Session["user"];
            }
        }
 public VendingMachineViewModel(VendingMachineCore vendingMachine)
 {
     this.vendingMachine = vendingMachine;
 }
Ejemplo n.º 4
0
        private void InitData()
        {
            var vendingInitState = new VendingInitState();
            vendingInitState.SetCoins(1, 100);
            vendingInitState.SetCoins(2, 100);
            vendingInitState.SetCoins(5, 100);
            vendingInitState.SetCoins(10, 100);
            vendingInitState.AddProduct("Чай", 13, 10);
            vendingInitState.AddProduct("Кофе", 18, 20);
            vendingInitState.AddProduct("Кофе с молоком", 21, 20);
            vendingInitState.AddProduct("Сок", 35, 15);
            vendingMachineCore = new VendingMachineCore(vendingInitState);

            user = new User();
            user.Purse.SetCoins(1, 10);
            user.Purse.SetCoins(2, 30);
            user.Purse.SetCoins(5, 20);
            user.Purse.SetCoins(10, 15);

            Session["vm"] = vendingMachineCore;
            Session["user"] = user;
        }