using System.Collections.Generic;
using System.Linq;
using System.Text;
using Edu.Common.Enum;
using Edu.Model.Entity.Finance;
using Edu.Model.ViewModel.Finance;

namespace Edu.Repository.Finance
{
    /// <summary>
    /// 财务单据币种仓储层
    /// </summary>
    public partial class RB_CurrencyRepository : BaseRepository<RB_Currency>
    {
        /// <summary>
        /// 表名称
        /// </summary>
        public string TableName { get { return nameof(RB_Currency); } }

        /// <summary>
        /// 获取币种列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List<RB_Currency> GetList(RB_Currency model)
        {
            string where = " WHERE 1=1 ";
            where += string.Format(" AND " + nameof(RB_Currency.Status) + "={0} ", (int)DateStateEnum.Normal);
            if (model.RB_Group_Id > 0)
            {
                where += string.Format(" AND " + nameof(RB_Currency.RB_Group_Id) + "={0} ", model.RB_Group_Id);
            }
            //if (model.RB_Branch_Id >= 0)
            //{
            //    where += string.Format(" AND " + nameof(RB_Currency.RB_Branch_Id) + "={0} ", model.RB_Branch_Id);
            //}
            if (!string.IsNullOrEmpty(model.Name))
            {
                where += string.Format(" AND " + nameof(RB_Currency_Extend.Name) + " like '%{0}%' ", model.Name);
            }
            if (model.IsStandardCurrency >= 0)
            {
                where += string.Format(" AND " + nameof(RB_Currency_Extend.IsStandardCurrency) + "={0} ", model.IsStandardCurrency);
            }
            return Get<RB_Currency>("select * from " + TableName + " " + where + " order by IsStandardCurrency desc ").ToList();
        }
    }
}
