public async Task <IUnitOfWorkResult> SaveChanges( CancellationToken cancellationToken = default(CancellationToken)) { try { var result = await this._dbContext.SaveChangesAsync(cancellationToken); // Give the unit of work result no exception, so that it knows // nothing went wrong, in saving the changes. return(new UnitOfWorkResult(null)); } catch (DbUpdateException exception) { var unitOfWorkException = new UnitOfWorkException( "UnitOfWork failed to save changes.", exception); return(new UnitOfWorkResult(unitOfWorkException)); } }
public UnitOfWorkResult(UnitOfWorkException exception) { this.Error = exception; }