This commit is contained in:
18942506660
2023-10-26 14:19:18 +08:00
parent 52c0f475d3
commit 404819d101
10 changed files with 201 additions and 1 deletions

View File

@@ -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<ChangeBoxRecord> 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;
}
}
}
}