using Learun.DataBase.Repository;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Learun.Application.CRM
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2017-07-11 14:47
/// 描 述:开票信息
///
public class CrmInvoiceService : RepositoryFactory
{
#region 获取数据
///
/// 获取列表
///
/// 分页
/// 查询参数
/// 返回分页列表
public IEnumerable GetPageList(Pagination pagination, string queryJson)
{
try
{
var expression = LinqExtensions.True();
var queryParam = queryJson.ToJObject();
//查询条件
if (!queryParam["keyword"].IsEmpty())
{
string keyword = queryParam["keyword"].ToString();
expression = expression.And(t => t.F_CustomerName.Contains(keyword));
}
return this.BaseRepository().FindList(expression, pagination);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 获取列表
///
/// 查询参数
/// 返回列表
public IEnumerable GetList(string queryJson)
{
try
{
return this.BaseRepository().IQueryable().ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 获取实体
///
/// 主键值
///
public CrmInvoiceEntity GetEntity(string keyValue)
{
try
{
return this.BaseRepository().FindEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
#region 提交数据
///
/// 删除数据
///
/// 主键
public void DeleteEntity(string keyValue)
{
try
{
this.BaseRepository().Delete(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 保存表单(新增、修改)
///
/// 主键值
/// 实体对象
///
public void SaveEntity(string keyValue, CrmInvoiceEntity entity)
{
try
{
if (!string.IsNullOrEmpty(keyValue))
{
entity.Modify(keyValue);
this.BaseRepository().Update(entity);
}
else
{
entity.Create();
this.BaseRepository().Insert(entity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
}
}