/// <summary> /// Closes the conenction with the DB /// </summary> public static void CloseConnection() { if (_session == null) { throw new ConnectionNotOpened(); } _session.Close(); _session = null; }
/// <summary> /// Creates a new connection to the repository, /// will throw an exception if the connection was already created /// </summary> /// <returns>The created connection</returns> public static IPersistanceConnection GetNewConnection() { if (_session != null) { throw new ConnectionAlreadyOpened(); } _session = GetConnectionProvider().GetConnection(); _session.SetNotifier(SesionScopeComplete); return(_session); }
/// <summary> /// Add dependency injection through the constructor /// </summary> /// <param name="connection">database connection</param> /// <param name="serviceClient">service client</param> public PartInvoiceController(IPersistanceConnection connection, IPartAvailabilityServiceClient serviceClient) { this.Connection = connection; this.ServiceClient = serviceClient; }
/// <summary> /// This is an scope helper to allow Idisposable and closing the backing connection /// </summary> public static void SesionScopeComplete() { _session = null; }