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); }
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); }
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); }