private void UpdateEquipment()
        {
            using (var context = new NinjaEntities())
            {
                var equipment = EquipmentVM.ToModel();

                context.Entry(equipment).State = EntityState.Modified;
                context.SaveChanges();
            }

            _equipmentListVM.HideUpdateEquipment();
        }
Example #2
0
        private void BuyItem()
        {
            if (SelectedEquipment != null && NinjaVM.Money > SelectedEquipment.EquipmentValue)
            {
                var InventoryItemVM = new InventoryVM();
                var inventoryItem   = InventoryItemVM.ToModel();


                inventoryItem.NinjaId          = NinjaVM.NinjaId;
                inventoryItem.IsUsingEquitment = false;
                inventoryItem.EquipmentId      = SelectedEquipment.EquipmentId;

                _inventoryListVM.EquipmentInventoryOC.Add(SelectedEquipment);


                using (var context = new NinjaEntities())
                {
                    EquipmentVM items = new EquipmentVM(context.Equipments.Where(e => e.EquipmentId == inventoryItem.EquipmentId).First());



                    NinjaVM.Money -= items.EquipmentValue;

                    var ninja = NinjaVM.ToModel();
                    context.Entry(ninja).State = EntityState.Modified;

                    context.InventoryItems.Add(inventoryItem);
                    context.Entry(inventoryItem).State = EntityState.Added;
                    context.SaveChanges();
                }


                this.RaisePropertyChanged();
                ShopItemsOC.Remove(SelectedEquipment);
            }
        }