Ejemplo n.º 1
0
        /// <summary>
        /// Called when an edit operation is aborted
        /// </summary>
        public void CancelEdit()
        {
            _editCount--;
            if (_editCount > 0 || _editContext == null)
            {
                return;
            }

            // End context
            _editContext.Dispose();
            _editContext = null;

            // Notify event waiters
            OnEditconcelled(EventArgs.Empty);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called before an edit operation begins on this object
        /// </summary>
        public void BeginEdit()
        {
            // If no db context is started, start one now
            if (_editContext == null)
            {
                // Notify event waiters
                OnEditBeginning(EventArgs.Empty);

                // Begin a db context
                _editContext = new SoCashDbContext();

                // Attach this entry to the context - initially unchanged, but changes will be tracked from here out
                _editContext.Entry(this).State = EntityState.Unchanged;

                // Notify event waiters
                OnEditBegun(EventArgs.Empty);
            }
            _editCount++;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called before an edit operation begins on this object
        /// </summary>
        public void BeginEdit()
        {
            // If no db context is started, start one now
            if (_editContext == null)
            {
                // Notify event waiters
                OnEditBeginning(EventArgs.Empty);

                // Begin a db context
                _editContext = new SoCashDbContext();

                // Attach this entry to the context - initially unchanged, but changes will be tracked from here out
                _editContext.Entry(this).State = EntityState.Unchanged;

                // Notify event waiters
                OnEditBegun(EventArgs.Empty);
            }
            _editCount++;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called after an edit operation ends on this object
        /// </summary>
        public void EndEdit()
        {
            _editCount--;
            if (_editCount > 0 || _editContext == null)
            {
                return;
            }

            // Notify event waiters
            OnEditEnding(EventArgs.Empty);

            // Commit changes to database
            _editContext.SaveChanges();

            // End context
            _editContext.Dispose();
            _editContext = null;

            // Notify event waiters
            OnEditEnded(EventArgs.Empty);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Allows mock framework to pass in a mock db context for testing
 /// </summary>
 /// <param name="dbContext">Alternate DB Context to use for service opperations</param>
 internal BaseService(SoCashDbContext dbContext)
 {
     DbContext = dbContext;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// No-argument constructor uses a real database context
 /// </summary>
 internal BaseService()
 {
     DbContext = new SoCashDbContext();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Allows mock framework to pass in a mock db context for testing
 /// </summary>
 /// <param name="dbContext">Alternate DB Context to use for service opperations</param>
 public DataService(SoCashDbContext dbContext)
     : base(dbContext)
 {
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Called when an edit operation is aborted
        /// </summary>
        public void CancelEdit()
        {
            _editCount--;
            if (_editCount > 0 || _editContext == null)
                return;

            // End context
            _editContext.Dispose();
            _editContext = null;

            // Notify event waiters
            OnEditconcelled(EventArgs.Empty);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Called after an edit operation ends on this object
        /// </summary>
        public void EndEdit()
        {
            _editCount--;
            if (_editCount > 0 || _editContext == null)
                return;

            // Notify event waiters
            OnEditEnding(EventArgs.Empty);

            // Commit changes to database
            _editContext.SaveChanges();

            // End context
            _editContext.Dispose();
            _editContext = null;

            // Notify event waiters
            OnEditEnded(EventArgs.Empty);
        }