protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
/// <summary> /// Gets all acceptors from the db. /// </summary> /// <returns>Observable collection of all acceptors</returns> public ObservableCollection <Acceptor> GetAcceptors() { ObservableCollection <Acceptor> Acceptors = new ObservableCollection <Acceptor>(); context.Dispose(); context = new dbModel(); context.Acceptors.Load(); Acceptors = context.Acceptors.Local; return(Acceptors); }
/// <summary> /// Gets all donors from the db. /// </summary> /// <returns>Observable collection of all donors</returns> public ObservableCollection <Donor> GetDonors() { ObservableCollection <Donor> Donors = new ObservableCollection <Donor>(); context.Dispose(); context = new dbModel(); context.Donors.Load(); Donors = context.Donors.Local; return(Donors); }
/// <summary> /// Gets all users from the db. /// </summary> /// <returns>Observable collection of all users</returns> public ObservableCollection <User> GetUsers() { ObservableCollection <User> Users = new ObservableCollection <User>(); context.Dispose(); context = new dbModel(); context.Users.Load(); Users = context.Users.Local; return(Users); }
/// <summary> /// Gets statistics value for <paramref name="BloodType"/> from db. /// </summary> /// <param name="BloodType">Type of the blood.</param> /// <returns>Percent of reserve for <paramref name="BloodType"/> /// or throws an NullReferenceException if there is no such blood type in Statistics table.</returns> /// <exception cref="System.NullReferenceException"></exception> public long GetStatistic(BloodTypeMarker BloodType) { try { context.Dispose(); context = new dbModel(); return((context.Statistics.Find(BloodType)).TotalAmount / 5000); } catch (NullReferenceException) { throw new NullReferenceException(); } }