test
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -79,5 +80,32 @@ namespace WMS.Web.Repositories
|
||||
return null;
|
||||
return result.Data.ToList();
|
||||
}
|
||||
|
||||
public IDbContextTransaction GetTransaction()
|
||||
{
|
||||
return _context.Database.BeginTransaction();
|
||||
}
|
||||
|
||||
public bool CommitTransaction(bool isRollback, IDbContextTransaction transaction)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (transaction == null)
|
||||
return true;
|
||||
|
||||
if (isRollback)
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,9 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddScoped<ILoginRepositories, LoginRepositories>();
|
||||
services.AddScoped<IBasicsRepositories, BasicsRepositories>();
|
||||
//services.AddScoped<IBasicsRepositories, BasicsRepositories>();
|
||||
services.AddScoped<IBoxRepositories, BoxRepositories>();
|
||||
|
||||
services.AddTransient<ITransactionRepositories, TransactionRepositories>();
|
||||
services.AddTransient<IBasicsRepositories, BasicsRepositories>();
|
||||
|
||||
services.AddTransient<IInStockRepositories, InStockRepositories>();
|
||||
services.AddTransient<IInStockTaskRepositories, InStockTaskRepositories>();
|
||||
|
||||
@@ -131,7 +131,8 @@ namespace WMS.Web.Repositories
|
||||
.Include(s => s.Details)
|
||||
.FirstOrDefaultAsync(f => f.Id == id);
|
||||
|
||||
return entity.Clone();
|
||||
//return entity.Clone();
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -339,14 +340,13 @@ namespace WMS.Web.Repositories
|
||||
try
|
||||
{
|
||||
var model = await _context.InStockTask
|
||||
.AsNoTracking()
|
||||
.Include(s=>s.Boxs)
|
||||
.Include(s => s.Details)
|
||||
.FirstOrDefaultAsync(f => f.Id == entity.Id);
|
||||
if (model == null)
|
||||
return null;
|
||||
_mapper.Map(entity, model);
|
||||
_mapper.ToMapList(entity.Boxs, model.Boxs);
|
||||
_mapper.ToMapList(entity.Details, model.Details);
|
||||
var result= await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
|
||||
Reference in New Issue
Block a user