142 lines
4.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Learun.DataBase.Repository;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Learun.Application.CRM
{
/// <summary>
/// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
/// Copyright (c) 2013-2018 勤一科技
/// 创 建:超级管理员
/// 日 期2017-07-11 09:58
/// 描 述:客户联系人
/// </summary>
public class CrmCustomerContactService : RepositoryFactory
{
#region
/// <summary>
/// 获取列表
/// </summary>
/// <param name="queryJson">查询参数</param>
/// <returns>返回列表</returns>
public IEnumerable<CrmCustomerContactEntity> GetList(string queryJson)
{
try
{
var expression = LinqExtensions.True<CrmCustomerContactEntity>();
var queryParam = queryJson.ToJObject();
//客户Id
if (!queryParam["customerId"].IsEmpty())
{
string CustomerId = queryParam["customerId"].ToString();
expression = expression.And(t => t.F_CustomerId == CustomerId);
}
//查询条件
if (!queryParam["keyword"].IsEmpty())
{
string keyword = queryParam["keyword"].ToString();
expression = expression.And(t => t.F_Contact.Contains(keyword) || t.F_Mobile.Contains(keyword) || t.F_Tel.Contains(keyword) || t.F_QQ.Contains(keyword));
}
return this.BaseRepository().IQueryable(expression).OrderByDescending(t => t.F_CreateDate).ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
/// <summary>
/// 获取实体
/// </summary>
/// <param name="keyValue">主键值</param>
/// <returns></returns>
public CrmCustomerContactEntity GetEntity(string keyValue)
{
try
{
return this.BaseRepository().FindEntity<CrmCustomerContactEntity>(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
#region
/// <summary>
/// 删除数据
/// </summary>
/// <param name="keyValue">主键</param>
public void DeleteEntity(string keyValue)
{
try
{
this.BaseRepository().Delete<CrmCustomerContactEntity>(t => t.F_CustomerContactId == keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
/// <summary>
/// 保存表单(新增、修改)
/// </summary>
/// <param name="keyValue">主键值</param>
/// <param name="entity">实体对象</param>
/// <returns></returns>
public void SaveEntity(string keyValue, CrmCustomerContactEntity 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
}
}