예제 #1
0
        public async Task <NFeResult> DeleteAll(CancellationToken cancellationToken)
        {
            try
            {
                cancellationToken.ThrowIfCancellationRequested();
                ThrowIfDisposed();
                NFeSet.Load();
                NFeSet.RemoveRange(NFeSet.Local);

                await SaveChangesAsync(cancellationToken);

                return(NFeResult.Success);
            }
            catch (DbUpdateConcurrencyException e)
            {
                return(NFeResult.Failed(e));
            }
            catch (DbUpdateException e)
            {
                return(NFeResult.Failed(e));
            }
            catch (Exception e)
            {
                return(NFeResult.Failed(e));
            }
        }
예제 #2
0
        public async Task <NFeResult> ImportTag(TNFe nfe, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            if (nfe == null)
            {
                throw new ArgumentNullException(nameof(nfe));
            }
            try
            {
                await NFeSet.AddAsync(nfe);
                await SaveChangesAsync(cancellationToken);

                return(NFeResult.Success);
            }
            catch (DbUpdateConcurrencyException e)
            {
                return(NFeResult.Failed(e));
            }
            catch (DbUpdateException e)
            {
                return(NFeResult.Failed(e));
            }
            catch (Exception e)
            {
                return(NFeResult.Failed(e));
            }
        }
예제 #3
0
        public static NFeResult Failed(DbUpdateConcurrencyException exception)
        {
            var result = new NFeResult
            {
                Succeeded = false,
                DbUpdateConcurrencyException = exception,
                NFeResultException           = NFeResultException.DbUpdateConcurrencyException
            };

            return(result);
        }
예제 #4
0
        public static NFeResult Failed(Exception exception)
        {
            var result = new NFeResult
            {
                Succeeded          = false,
                Exception          = exception,
                NFeResultException = NFeResultException.Exception
            };

            return(result);
        }
예제 #5
0
        public static NFeResult Failed(DbUpdateException exception)
        {
            var result = new NFeResult
            {
                Succeeded          = false,
                DbUpdateException  = exception,
                NFeResultException = NFeResultException.DbUpdateException,
                ErrorNumber        = ((System.Data.SqlClient.SqlException)exception.InnerException).Number
            };

            return(result);
        }