using HKLib.SQLHelper.Entity;
using System;
using System.Collections.Generic;
using System.Text;

namespace HKLib.SQLHelper
{
    public class SqlLogic
    {
        public static PriceModel GetPrice()
        {
            return DbContext.Context.Queryable<PriceModel>().First();
        }
        public static PriceModel AddPrice(PriceModel input)
        {
            DbContext.Context.Deleteable<PriceModel>().Where(t => t.Id != 0).ExecuteCommand();
            return DbContext.Context.Insertable(input).ExecuteReturnEntity();
        }
        public static AdminModel AddAmin(string CardNo)
        {
            var d = new AdminModel
            {
                Name="管理员"+ CardNo,
                CardNo = CardNo
            };
            return DbContext.Context.Insertable(d).ExecuteReturnEntity();
        }

        public static AdminModel GetAdmin(string CardNo)
        {
            return DbContext.Context.Queryable<AdminModel>().First(t => t.CardNo == CardNo);
        }
        public static int GetAdmin()
        {
            return DbContext.Context.Queryable<AdminModel>().Select(t => t.Id).Count();
        }
    }
}
