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 MoveBoxRecordRepositories: IMoveBoxRecordRepositories
{
private readonly IMapper _mapper;
private readonly IServiceProvider _serviceProvider;
private readonly RepositoryDbContext _context;
public MoveBoxRecordRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider)
{
_context = context;
_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;
}
}
}
}