添加序列号记录
This commit is contained in:
@@ -30,7 +30,7 @@ namespace WMS.Web.Repositories.Configuration
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
{
|
||||
|
||||
//改箱
|
||||
builder.Entity<ChangeBoxRecord>(ent =>
|
||||
@@ -48,7 +48,14 @@ namespace WMS.Web.Repositories.Configuration
|
||||
ent.ToTable("t_wms_movebox_record");
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
|
||||
|
||||
//序列号操作记录
|
||||
builder.Entity<SerialNumberOperate>(ent =>
|
||||
{
|
||||
ent.ToTable("t_wms_serialnumberoperate");
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
|
||||
#region 出库单
|
||||
builder.Entity<OutStock>(ent =>
|
||||
{
|
||||
@@ -66,7 +73,7 @@ namespace WMS.Web.Repositories.Configuration
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
#endregion
|
||||
|
||||
|
||||
#region 出库任务单
|
||||
builder.Entity<OutStockTask>(ent =>
|
||||
{
|
||||
@@ -84,7 +91,7 @@ namespace WMS.Web.Repositories.Configuration
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
#endregion
|
||||
|
||||
|
||||
#region 盘点单
|
||||
builder.Entity<TakeStock>(ent =>
|
||||
{
|
||||
@@ -223,6 +230,7 @@ namespace WMS.Web.Repositories.Configuration
|
||||
base.OnModelCreating(builder);
|
||||
}
|
||||
|
||||
public DbSet<SerialNumberOperate> SerialNumberOperate { get; set; }
|
||||
public DbSet<ChangeBoxRecord> ChangeBoxRecord { get; set; }
|
||||
public DbSet<MoveBoxRecord> MoveBoxRecord { get; set; }
|
||||
public DbSet<OutStock> OutStock { get; set; }
|
||||
|
||||
@@ -42,10 +42,10 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
services.AddTransient<IInventoryDetailsRepositories, InventoryDetailsRepositories>();
|
||||
services.AddTransient<IInventoryInOutDetailsRepositories, InventoryInOutDetailsRepositories>();
|
||||
services.AddTransient<IBoxInventoryRepositories, BoxInventoryRepositories>();
|
||||
|
||||
|
||||
|
||||
|
||||
services.AddTransient<ISerialNumberOperateRepositories, SerialNumberOperateRepositories>();
|
||||
services.AddTransient<IChangeBoxRecordRepositories, ChangeBoxRecordRepositories>();
|
||||
services.AddTransient<IMoveBoxRecordRepositories, MoveBoxRecordRepositories>();
|
||||
services.AddTransient<IOutStockRepositories, OutStockRepositories>();
|
||||
|
||||
50
src/WMS.Web.Repositories/SerialNumberOperateRepositories.cs
Normal file
50
src/WMS.Web.Repositories/SerialNumberOperateRepositories.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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 SerialNumberOperateRepositories: ISerialNumberOperateRepositories
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly RepositoryDbContext _context;
|
||||
|
||||
public SerialNumberOperateRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider)
|
||||
{
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public async Task<bool> AddRange(List<SerialNumberOperate> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
if (entitys != null && entitys.Count != 0)
|
||||
{
|
||||
await _context.SerialNumberOperate.AddRangeAsync(entitys);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user