using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using DOAN.Model;
using DOAN.Model.Dto;
using DOAN.Model.MES.material.Dto;
using DOAN.Model.MES.material;
using DOAN.Repository;
using DOAN.Service.MES.material.IService;
using System.Linq;
namespace DOAN.Service.MES.material
{
///
/// 北泽线边库供应商Service业务层处理
///
[AppService(ServiceType = typeof(IMaterialPartsSuppliersService), ServiceLifetime = LifeTime.Transient)]
public class MaterialPartsSuppliersService : BaseService, IMaterialPartsSuppliersService
{
///
/// 查询北泽线边库供应商列表
///
///
///
public PagedInfo GetList(MaterialPartsSuppliersQueryDto parm)
{
var predicate = Expressionable.Create();
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
public List GetListSupplier(string query)
{
return Queryable()
.WhereIF(!string.IsNullOrEmpty(query),x => x.SupplierName.Contains(query))
.Select(x => new MaterialPartsSuppliersDto()
{
SupplierId = x.SupplierId,
SupplierName = x.SupplierName
})
.ToList();
}
///
/// 获取详情
///
///
///
public MaterialPartsSuppliers GetInfo(int SupplierId)
{
var response = Queryable()
.Where(x => x.SupplierId == SupplierId)
.First();
return response;
}
///
/// 添加北泽线边库供应商
///
///
///
public MaterialPartsSuppliers AddMaterialPartsSuppliers(MaterialPartsSuppliers model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改北泽线边库供应商
///
///
///
public int UpdateMaterialPartsSuppliers(MaterialPartsSuppliers model)
{
//var response = Update(w => w.SupplierId == model.SupplierId, it => new MaterialPartsSuppliers()
//{
// SupplierName = model.SupplierName,
// ContactPerson = model.ContactPerson,
// Phone = model.Phone,
// Email = model.Email,
// Address = model.Address,
// CreatedAt = model.CreatedAt,
// UpdatedAt = model.UpdatedAt,
//});
//return response;
return Update(model, true);
}
}
}