Exemple #1
0
        public bool Update(PartModel partModel)
        {
            var original = DatabaseManager.Instance.Parts.Find(partModel.Id);

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

            return(false);
        }
Exemple #2
0
        private Part ToDbModel(PartModel partModel)
        {
            var partDb = new Part
            {
                Part_ID          = partModel.Id,
                Part_Description = partModel.Description,
                Part_UnitPrice   = partModel.UnitPrice,
                Part_QtyOnHand   = partModel.QtyOnHand,
                Part_StockValue  = (partModel.UnitPrice * partModel.QtyOnHand),
                Part_AddedDate   = partModel.CreatedDate,
            };

            return(partDb);
        }
Exemple #3
0
        public PartModel Add(PartModel partModel)
        {
            var partDb = ToDbModel(partModel);

            DatabaseManager.Instance.Parts.Add(partDb);
            DatabaseManager.Instance.SaveChanges();

            partModel = new PartModel
            {
                Id          = partDb.Part_ID,
                Description = partDb.Part_Description,
                UnitPrice   = partDb.Part_UnitPrice,
                QtyOnHand   = partDb.Part_QtyOnHand,
                StockValue  = partDb.Part_StockValue,
                CreatedDate = partDb.Part_AddedDate
            };
            return(partModel);
        }