You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.3 KiB
68 lines
2.3 KiB
using Serilog;
|
|
using WMS_GIRAF_Interface.Data;
|
|
using WMS_GIRAF_Interface.Entities;
|
|
using WMS_GIRAF_Interface.Repositories.Interface;
|
|
|
|
|
|
namespace WMS_GIRAF_Interface.Repositories.Implement;
|
|
|
|
public class StorageMainRepository:IStorageMainRepository
|
|
{
|
|
private readonly MichelinDbContext _context;
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
public StorageMainRepository(MichelinDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public STORAGE_MAIN? GetStorageMain(string type, string filterInfo)
|
|
{
|
|
STORAGE_MAIN? storageMain = type switch
|
|
{
|
|
"barcode" => _context.Storage_Main.FirstOrDefault(x => x.STOCK_BARCODE == filterInfo),
|
|
"storageId" => _context.Storage_Main.FirstOrDefault(x => x.STORAGE_ID == Convert.ToInt32(filterInfo)),
|
|
"requestNumber" => _context.Storage_Main.FirstOrDefault(x => x.requestNumber == filterInfo),
|
|
_ => _context.Storage_Main.FirstOrDefault(x => x.STOCK_BARCODE == filterInfo)
|
|
};
|
|
|
|
return storageMain;
|
|
}
|
|
public bool UpdateStorageMain(STORAGE_MAIN storageMain)
|
|
{
|
|
if (storageMain == null || storageMain.STORAGE_ID == 0)
|
|
{
|
|
throw new ArgumentNullException(nameof(UpdateStorageMain));
|
|
}
|
|
_context.Storage_Main.Update(storageMain);
|
|
Log.Information($"Update storage main info({storageMain.STOCK_BARCODE});");
|
|
_context.SaveChanges();
|
|
return true;
|
|
}
|
|
|
|
public bool DeleteStorageMain(STORAGE_MAIN storageMain)
|
|
{
|
|
if(storageMain == null || storageMain.STORAGE_ID == 0)
|
|
{
|
|
throw new ArgumentNullException(nameof(DeleteStorageMain));
|
|
}
|
|
_context.Storage_Main.Remove(storageMain);
|
|
_context.SaveChanges();
|
|
Log.Information($"Deleted storage main info({storageMain.STOCK_BARCODE});");
|
|
return true;
|
|
}
|
|
public bool AddStorageMain(STORAGE_MAIN storageMain)
|
|
{
|
|
if (storageMain==null)
|
|
{
|
|
throw new ArgumentNullException(nameof(AddStorageMain));
|
|
}
|
|
_context.Storage_Main.Add(storageMain);
|
|
_context.SaveChanges();
|
|
Log.Information($"Add storage main info({storageMain.STOCK_BARCODE});");
|
|
return true;
|
|
}
|
|
}
|