133 lines
4.5 KiB
C#
133 lines
4.5 KiB
C#
using Air.Model;
|
|
using Air.Model.AirAdminViewModel;
|
|
using Mini.Common;
|
|
using Mini.Model;
|
|
using Mini.Model.Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Mini.Services.Bas
|
|
{
|
|
public class BasSupplierService : IBasSupplierService
|
|
{
|
|
private readonly IAdminRepository<Bas_Supplier> _bassupplierRepository;
|
|
|
|
public BasSupplierService(IAdminRepository<Bas_Supplier> bassupplierRepository)
|
|
{
|
|
_bassupplierRepository = bassupplierRepository;
|
|
}
|
|
public List<Bas_Supplier> GetList()
|
|
{
|
|
return _bassupplierRepository.Table.ToList();
|
|
}
|
|
public List<Bas_Supplier> GetList(ref Pager pager, string name, string licence, string linkman, string linkphone)
|
|
{
|
|
IQueryable<Bas_Supplier> query = _bassupplierRepository.Table;
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
query = query.Where(m => m.SupplierName.Contains(name) || m.FullName.Contains(name));
|
|
}
|
|
if (!string.IsNullOrEmpty(licence))
|
|
{
|
|
query = query.Where(m => m.Licence == licence);
|
|
}
|
|
if (!string.IsNullOrEmpty(linkman))
|
|
{
|
|
query = query.Where(m => m.LinkMan == linkman);
|
|
}
|
|
if (!string.IsNullOrEmpty(linkphone))
|
|
{
|
|
query = query.Where(m => m.LinkPhone == linkphone);
|
|
}
|
|
|
|
query = query.OrderByDescending(m => m.CTime);
|
|
PagerUtil.SetPager<Bas_Supplier>(ref query, ref pager);//分页
|
|
return query.ToList();
|
|
}
|
|
public Bas_SupplierModel GetModel(int id)
|
|
{
|
|
Bas_Supplier m = _bassupplierRepository.Get(w => w.SupplierId == id);
|
|
Bas_SupplierModel model = new Bas_SupplierModel()
|
|
{
|
|
Address = m.Address,
|
|
CreateUser = m.CreateUser,
|
|
FullName = m.FullName,
|
|
Licence = m.Licence,
|
|
LinkMan = m.LinkMan,
|
|
LinkPhone = m.LinkPhone,
|
|
SupplierId = m.SupplierId,
|
|
SupplierName = m.SupplierName,
|
|
bankname = m.bankname,
|
|
accountnumber = m.accountnumber,
|
|
accountname = m.accountname
|
|
};
|
|
return model;
|
|
}
|
|
public bool Create(Bas_SupplierModel m, ref ValidationErrors erro)
|
|
{
|
|
bool result = false;
|
|
try
|
|
{
|
|
|
|
Bas_Supplier model = new Bas_Supplier()
|
|
{
|
|
Address = m.Address,
|
|
CreateUser = m.CreateUser.Value,
|
|
CTime = DateTime.Now,
|
|
FullName = m.FullName,
|
|
Licence = m.Licence,
|
|
LinkMan = m.LinkMan,
|
|
LinkPhone = m.LinkPhone,
|
|
SupplierName = m.SupplierName,
|
|
accountname = m.accountname,
|
|
accountnumber = m.accountnumber,
|
|
bankname = m.bankname
|
|
};
|
|
_bassupplierRepository.Add(model);
|
|
result = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
erro.Add("出现错误");
|
|
}
|
|
return result;
|
|
}
|
|
public bool Update(Bas_SupplierModel m, ref ValidationErrors erro)
|
|
{
|
|
bool result = false;
|
|
try
|
|
{
|
|
Bas_Supplier mdel = _bassupplierRepository.Get(x => x.SupplierId == m.SupplierId);
|
|
if (mdel == null)
|
|
{
|
|
erro.Add("找不到数据!");
|
|
return false;
|
|
}
|
|
mdel.Address = m.Address;
|
|
mdel.UpdateUser = m.UpdateUser.Value;
|
|
mdel.UTime = DateTime.Now;
|
|
mdel.FullName = m.FullName;
|
|
mdel.Licence = m.Licence;
|
|
mdel.LinkMan = m.LinkMan;
|
|
mdel.LinkPhone = m.LinkPhone;
|
|
mdel.SupplierName = m.SupplierName;
|
|
mdel.accountname = m.accountname;
|
|
mdel.accountnumber = m.accountnumber;
|
|
mdel.bankname = m.bankname;
|
|
_bassupplierRepository.Update(mdel);
|
|
result = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
erro.Add("出现错误");
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|