diff --git a/src/WMS.Web.Domain/Infrastructure/IChangeBoxRecordRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IChangeBoxRecordRepositories.cs index bb0f698a..797c2e2e 100644 --- a/src/WMS.Web.Domain/Infrastructure/IChangeBoxRecordRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IChangeBoxRecordRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface IChangeBoxRecordRepositories { + // 新增 + Task Add(ChangeBoxRecord entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Domain/Infrastructure/IMoveBoxRecordRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IMoveBoxRecordRepositories.cs index 7e74fced..cc9f6cf2 100644 --- a/src/WMS.Web.Domain/Infrastructure/IMoveBoxRecordRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IMoveBoxRecordRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface IMoveBoxRecordRepositories { + // 新增 + Task Add(MoveBoxRecord entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Domain/Infrastructure/IOutStockRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IOutStockRepositories.cs index dd454704..71369778 100644 --- a/src/WMS.Web.Domain/Infrastructure/IOutStockRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IOutStockRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface IOutStockRepositories { + // 新增 + Task Add(OutStock entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs index 75e181a9..8fdfb566 100644 --- a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface IOutStockTaskRepositories { + // 新增 + Task Add(OutStockTask entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Domain/Infrastructure/ITakeStockRepositories.cs b/src/WMS.Web.Domain/Infrastructure/ITakeStockRepositories.cs index fcd8ae2c..e43f0388 100644 --- a/src/WMS.Web.Domain/Infrastructure/ITakeStockRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/ITakeStockRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface ITakeStockRepositories { + // 新增 + Task Add(TakeStock entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Repositories/ChangeBoxRecordRepositories.cs b/src/WMS.Web.Repositories/ChangeBoxRecordRepositories.cs index 1d4266ab..6aa37b38 100644 --- a/src/WMS.Web.Repositories/ChangeBoxRecordRepositories.cs +++ b/src/WMS.Web.Repositories/ChangeBoxRecordRepositories.cs @@ -1,13 +1,16 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; namespace WMS.Web.Repositories { - public class ChangeBoxRecordRepositories: IChangeBoxRecordRepositories + public class ChangeBoxRecordRepositories : IChangeBoxRecordRepositories { private readonly IMapper _mapper; private readonly IServiceProvider _serviceProvider; @@ -20,5 +23,34 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + + public async Task Add(ChangeBoxRecord entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.ChangeBoxRecord.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } } diff --git a/src/WMS.Web.Repositories/MoveBoxRecordRepositories.cs b/src/WMS.Web.Repositories/MoveBoxRecordRepositories.cs index 7ca4bb7a..94355151 100644 --- a/src/WMS.Web.Repositories/MoveBoxRecordRepositories.cs +++ b/src/WMS.Web.Repositories/MoveBoxRecordRepositories.cs @@ -1,7 +1,10 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; @@ -20,5 +23,39 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(MoveBoxRecord entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.MoveBoxRecord.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } } diff --git a/src/WMS.Web.Repositories/OutStockRepositories.cs b/src/WMS.Web.Repositories/OutStockRepositories.cs index 934513e9..c5721bb3 100644 --- a/src/WMS.Web.Repositories/OutStockRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockRepositories.cs @@ -1,7 +1,10 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; @@ -20,5 +23,39 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(OutStock entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.OutStock.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } } diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs index 46fd376a..5a5ff771 100644 --- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs @@ -1,7 +1,10 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; @@ -20,5 +23,39 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(OutStockTask entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.OutStockTask.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } } diff --git a/src/WMS.Web.Repositories/TakeStockRepositories.cs b/src/WMS.Web.Repositories/TakeStockRepositories.cs index aa5bd93e..09542d0c 100644 --- a/src/WMS.Web.Repositories/TakeStockRepositories.cs +++ b/src/WMS.Web.Repositories/TakeStockRepositories.cs @@ -1,7 +1,10 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; @@ -20,5 +23,39 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(TakeStock entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.TakeStock.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } }