using System;
using System.Data;
using System.Collections.Generic;
using DotNet.FrameWork.Data;
using HaTeam.Dd.Model;
namespace HaTeam.Dd.BLL
{
	/// <summary>
	/// Dd_Like
	/// </summary>
	public partial class Dd_Like
	{
		private readonly HaTeam.Dd.DAL.Dd_Like dal=new HaTeam.Dd.DAL.Dd_Like();
		public Dd_Like()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int Like_ID)
		{
			return dal.Exists(Like_ID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(HaTeam.Dd.Model.Dd_Like model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(HaTeam.Dd.Model.Dd_Like model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Like_ID)
		{
			
			return dal.Delete(Like_ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string Like_IDlist )
		{
			return dal.DeleteList(Like_IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public HaTeam.Dd.Model.Dd_Like GetModel(int Like_ID)
		{
			
			return dal.GetModel(Like_ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public HaTeam.Dd.Model.Dd_Like GetModelByCache(int Like_ID)
		{
			
			string CacheKey = "Dd_LikeModel-" + Like_ID;
			object objModel = DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(Like_ID);
					if (objModel != null)
					{
						int ModelCache = ConfigHelper.GetConfigInt("ModelCache");
						DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (HaTeam.Dd.Model.Dd_Like)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<HaTeam.Dd.Model.Dd_Like> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<HaTeam.Dd.Model.Dd_Like> DataTableToList(DataTable dt)
		{
			List<HaTeam.Dd.Model.Dd_Like> modelList = new List<HaTeam.Dd.Model.Dd_Like>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				HaTeam.Dd.Model.Dd_Like model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new HaTeam.Dd.Model.Dd_Like();
					if(dt.Rows[n]["Like_ID"].ToString()!="")
					{
						model.Like_ID=int.Parse(dt.Rows[n]["Like_ID"].ToString());
					}
					if(dt.Rows[n]["Like_TypeID"].ToString()!="")
					{
						model.Like_TypeID=int.Parse(dt.Rows[n]["Like_TypeID"].ToString());
					}
					if(dt.Rows[n]["Like_ArticleID"].ToString()!="")
					{
						model.Like_ArticleID=int.Parse(dt.Rows[n]["Like_ArticleID"].ToString());
					}
					if(dt.Rows[n]["Like_UserID"].ToString()!="")
					{
						model.Like_UserID=int.Parse(dt.Rows[n]["Like_UserID"].ToString());
					}
					model.Like_Guid=dt.Rows[n]["Like_Guid"].ToString();
					if(dt.Rows[n]["Like_Datetime"].ToString()!="")
					{
						model.Like_Datetime=DateTime.Parse(dt.Rows[n]["Like_Datetime"].ToString());
					}
					if(dt.Rows[n]["Like_UpDatetime"].ToString()!="")
					{
						model.Like_UpDatetime=DateTime.Parse(dt.Rows[n]["Like_UpDatetime"].ToString());
					}
					if(dt.Rows[n]["Like_Verify"].ToString()!="")
					{
						model.Like_Verify=int.Parse(dt.Rows[n]["Like_Verify"].ToString());
					}
					if(dt.Rows[n]["Like_Lock"].ToString()!="")
					{
						model.Like_Lock=int.Parse(dt.Rows[n]["Like_Lock"].ToString());
					}
					if(dt.Rows[n]["Like_State"].ToString()!="")
					{
						model.Like_State=int.Parse(dt.Rows[n]["Like_State"].ToString());
					}
					if(dt.Rows[n]["Like_Delete"].ToString()!="")
					{
						model.Like_Delete=int.Parse(dt.Rows[n]["Like_Delete"].ToString());
					}
					if(dt.Rows[n]["Like_Count"].ToString()!="")
					{
						model.Like_Count=int.Parse(dt.Rows[n]["Like_Count"].ToString());
					}
					if(dt.Rows[n]["Like_Order"].ToString()!="")
					{
						model.Like_Order=int.Parse(dt.Rows[n]["Like_Order"].ToString());
					}
					model.Like_Remark=dt.Rows[n]["Like_Remark"].ToString();
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

