Пример #1
0
        public bool Update(InventoryItemModel inventoryItemModel)
        {
            var original = DatabaseManager.Instance.Items.Find(inventoryItemModel.id);

            if (original != null)
            {
                DatabaseManager.Instance.Entry(original).CurrentValues.SetValues(ToDbModel(inventoryItemModel));
                DatabaseManager.Instance.SaveChanges();
                return(true);
            }

            return(false);
        }
Пример #2
0
        private Items ToDbModel(InventoryItemModel inventoryItemModel)
        {
            var inventoryItem = new Items
            {
                id          = inventoryItemModel.id,
                description = inventoryItemModel.description,
                location    = inventoryItemModel.location,
                quantity    = inventoryItemModel.quantity,
                price       = inventoryItemModel.price,
                cost        = inventoryItemModel.cost,
                createDate  = inventoryItemModel.createDate,
            };

            return(inventoryItem);
        }
Пример #3
0
        public InventoryItemModel Add(InventoryItemModel inventoryItemModel)
        {
            Items inventoryItem = ToDbModel(inventoryItemModel);

            DatabaseManager.Instance.Items.Add(inventoryItem);
            DatabaseManager.Instance.SaveChanges();

            inventoryItemModel = new InventoryItemModel
            {
                id          = inventoryItem.id,
                description = inventoryItem.description,
                location    = inventoryItem.location,
                quantity    = inventoryItem.quantity,
                price       = (float)inventoryItem.price,
                cost        = (float)inventoryItem.cost,
                createDate  = inventoryItem.createDate,
            };
            return(inventoryItemModel);
        }