using CP.Cache;
using CP.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace CP.Business
{
public class CzBll : DataConnect
{
///
/// 缓存
///
static WMCache cache = WMCache.GetCacheService();
public static List GetList()
{
string key = string.Format(CacheKeys.SYSTEM_CZCLASS);
List list = cache.GetObject>(key) as List;
if (list == null)
{
var dc = new DataConnect();
list = dc.db.Fetch("where state=1 order by seq asc");
//list = dc.db.Fetch("where state>-1 order by seq asc");
cache.AddObject(key, list, (int)CacheTime.System);
}
return list;
}
public static List GetAllList()
{
string key = string.Format(CacheKeys.CzAll);
List list = cache.GetObject>(key) as List;
if (list == null)
{
var dc = new DataConnect();
list = dc.db.Fetch("where 1=1 order by seq asc");
//list = dc.db.Fetch("where state>-1 order by seq asc");
cache.AddObject(key, list, (int)CacheTime.System);
}
return list;
}
public static Cz GetCz(int cid)
{
var list = GetList();
return list.FirstOrDefault(m => m.cid == cid) ?? new Cz();
}
public static Cz GetCz(string ename)
{
var list = GetList();
return list.FirstOrDefault(m => m.ename == ename) ?? new Cz();
}
///
/// 获取全部彩种list
///
///
///
public static SelectList DropDownList(string tip = "")
{
var list = GetList();
List datas = new List();
if (!string.IsNullOrWhiteSpace(tip))
{
datas.Add(new SelectListItem() { Text = tip, Value = "0" });
}
if (list != null && list.Count > 0)
{
foreach (var cz in list)
{
datas.Add(new SelectListItem() { Text = cz.name, Value = cz.cid.ToString() });
}
}
return new SelectList(datas, "Value", "Text");
}
public static List GetCzTypeList(int type)
{
var list = GetList();
return list.Where(m => m.type == type).ToList() ?? new List();
}
}
}