增加序列号结构表

This commit is contained in:
18942506660
2023-11-11 10:23:59 +08:00
parent 7707c1615d
commit 27dac5680d
12 changed files with 259 additions and 37 deletions

View File

@@ -0,0 +1,53 @@
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
{
/// <summary>
/// 序列号
/// </summary>
public class SerialNumbersRepositories: ISerialNumbersRepositories
{
private readonly IMapper _mapper;
private readonly IServiceProvider _serviceProvider;
private readonly RepositoryDbContext _context;
public SerialNumbersRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider)
{
_context = context;
_mapper = mapper;
_serviceProvider = serviceProvider;
}
public async Task<bool> AddRange(List<SerialNumbers> entitys, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
if (entitys != null && entitys.Count != 0)
{
await _context.SerialNumbers.AddRangeAsync(entitys);
await _context.SaveChangesAsync();
}
if (_transaction != null)
_transaction.Commit();
return true;
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
}
}
}