using Lottomat.Application.Entity.SystemManage;
using Lottomat.Application.IService.SystemManage;
using Lottomat.Application.Service.SystemManage;
using Lottomat.Cache.Factory;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Lottomat.Application.Busines.SystemManage
{
///
/// 版 本 1.0
/// Copyright (c) 2016-2017
/// 创建人:赵轶
/// 日 期:2015.11.12 16:40
/// 描 述:区域管理
///
public class AreaBLL
{
private IAreaService service = new AreaService();
///
/// 缓存key
///
private string cacheKey = "areaCache";
#region 获取数据
///
/// 区域列表
///
///
public IEnumerable GetList()
{
var cacheList = CacheFactory.Cache().GetCache>(cacheKey);
if (cacheList == null)
{
var data = service.GetList();
CacheFactory.Cache().WriteCache(data, cacheKey);
return data;
}
else
{
return cacheList;
}
}
///
/// 区域列表
///
/// 节点Id
/// 关键字查询
///
public IEnumerable GetList(string parentId, string keyword = "")
{
return service.GetList(parentId, keyword);
}
///
/// 区域列表(主要是给绑定数据源提供的)
///
/// 节点Id
///
public IEnumerable GetAreaList(string parentId)
{
return this.GetList().Where(t => t.EnabledMark == 1 && t.ParentId == parentId);
}
///
/// 区域实体
///
/// 主键值
///
public AreaEntity GetEntity(string keyValue)
{
return service.GetEntity(keyValue);
}
#endregion
#region 提交数据
///
/// 删除区域
///
/// 主键
public void RemoveForm(string keyValue)
{
try
{
service.RemoveForm(keyValue);
CacheFactory.Cache().RemoveCache(cacheKey);
}
catch (Exception)
{
throw;
}
}
///
/// 保存区域表单(新增、修改)
///
/// 主键值
/// 区域实体
///
public void SaveForm(string keyValue, AreaEntity areaEntity)
{
try
{
service.SaveForm(keyValue, areaEntity);
CacheFactory.Cache().RemoveCache(cacheKey);
}
catch (Exception)
{
throw;
}
}
#endregion
}
}