1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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
- {
- /// <summary>
- /// 缓存
- /// </summary>
- static WMCache cache = WMCache.GetCacheService();
- public static List<Cz> GetList()
- {
- string key = string.Format(CacheKeys.SYSTEM_CZCLASS);
- List<Cz> list = cache.GetObject<List<Cz>>(key) as List<Cz>;
- if (list == null)
- {
- var dc = new DataConnect();
- list = dc.db.Fetch<Cz>("where state=1 order by seq asc");
- //list = dc.db.Fetch<Cz>("where state>-1 order by seq asc");
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list;
- }
- public static List<Cz> GetAllList()
- {
- string key = string.Format(CacheKeys.CzAll);
- List<Cz> list = cache.GetObject<List<Cz>>(key) as List<Cz>;
- if (list == null)
- {
- var dc = new DataConnect();
- list = dc.db.Fetch<Cz>("where 1=1 order by seq asc");
- //list = dc.db.Fetch<Cz>("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();
- }
- /// <summary>
- /// 获取全部彩种list
- /// </summary>
- /// <param name="tip"></param>
- /// <returns></returns>
- public static SelectList DropDownList(string tip = "")
- {
- var list = GetList();
- List<SelectListItem> datas = new List<SelectListItem>();
- 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<Cz> GetCzTypeList(int type)
- {
- var list = GetList();
- return list.Where(m => m.type == type).ToList() ?? new List<Cz>();
- }
- }
- }
|