/// <summary> /// Gets the existing connection if any for DB /// Used for updating an existing medicine /// </summary> /// <param name="medicineId">Medicine to be retrieved from DB</param> public MedicineViewModel(int medicineId) { db = App.ViewModel.db; db.Refresh(RefreshMode.OverwriteCurrentValues, db.Medicines); // Clear any unsaved changes Medicine = db.Medicines.SingleOrDefault(m => m.Id == medicineId); }
/// <summary> /// Gets the existing connection if any for DB /// Creates an empty Medicine instance /// Used for creating a new medicine as we do not have any ID for it yet /// </summary> public MedicineViewModel() { db = App.ViewModel.db; db.Refresh(RefreshMode.OverwriteCurrentValues, db.Medicines); // Clear any unsaved changes Medicine = new Medicine(); }