Beispiel #1
0
 public ShopVM(MainViewModel main)
 {
     _main          = main;
     _selectedNinja = _main.SelectedNinja;
     SelectHead     = new RelayCommand(() =>
     {
         changeSelectedCategoryEquipment("Head");
     });
     SelectShoulders = new RelayCommand(() =>
     {
         changeSelectedCategoryEquipment("Shoulders");
     });
     SelectChest = new RelayCommand(() =>
     {
         changeSelectedCategoryEquipment("Chest");
     });
     SelectBelt = new RelayCommand(() =>
     {
         changeSelectedCategoryEquipment("Belt");
     });
     SelectLegs = new RelayCommand(() =>
     {
         changeSelectedCategoryEquipment("Legs");
     });
     SelectBoots = new RelayCommand(() =>
     {
         changeSelectedCategoryEquipment("Boots");
     });
     BuyCommand  = new RelayCommand(buy);
     SellCommand = new RelayCommand(sell);
 }
Beispiel #2
0
 private void reloadInventory()
 {
     using (var context = new NinjaManagerEntities())
     {
         int ninjaID = SelectedNinja.ToModel().Id;
         var ninja   = context.Ninja.Include("Equipment").Where(n => n.Id == ninjaID).Single();
         _selectedNinja = new NinjaVM(ninja);
     }
 }
Beispiel #3
0
 public CreateNinjaVM(MainViewModel main)
 {
     _main            = main;
     Ninja            = new NinjaVM();
     SaveNinjaCommand = new RelayCommand(() =>
     {
         using (var context = new NinjaManagerEntities())
         {
             context.Ninja.Add(Ninja.ToModel());
             context.SaveChanges();
             _main.Ninjas.Add(Ninja);
         }
     });
 }
Beispiel #4
0
        private void buy()
        {
            using (var context = new NinjaManagerEntities())
            {
                int       ninjaId   = _main.SelectedNinja.ToModel().Id;
                var       item      = context.Ninja.Include("Equipment").Where(Item => Item.Id == ninjaId).Single();
                Equipment eq        = SelectedEquipment.ToModel();
                Equipment equipment = context.Equipment.Where(e => e.Id == eq.Id).Single();
                equipment.Ninja.Add(item);
                item.Gold -= SelectedEquipment.Gold;
                context.SaveChanges();

                Ninja = new NinjaVM(item);
                Ninja.Inventory.Add(SelectedEquipment);
                CanBuy  = buyCheck();
                CanSell = sellCheck();
            }
        }
Beispiel #5
0
 public EquipmentVM(Equipment equipment, NinjaVM ninja)
 {
     this._equipment = equipment;
     Ninja           = new ObservableCollection <NinjaVM>();
     Ninja.Add(ninja);
 }
 public EditNinjaViewModel(NinjaVM selectedNinja, NinjaListViewModel listViewModel)
 {
     this._selectedNinja = selectedNinja;
     this._listViewModel = listViewModel;
     SaveCommand         = new RelayCommand(saveCommand);
 }