using Edu.Model.Entity.User;
using Edu.Repository.User;
using System.Collections.Generic;
using VT.FW.DB;

namespace Edu.Module.User
{
    /// <summary>
    /// 助教处理类
    /// </summary>
    public class AssistModule
    {
        /// <summary>
        /// 助教仓储层对象
        /// </summary>
        private readonly RB_AssistRepository assistRepository = new RB_AssistRepository();

        /// <summary>
        /// 添加修改助教
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool SetAssistModule(RB_Assist model)
        {
            bool flag = false;
            if (model.AId > 0)
            {
                Dictionary<string, object> fileds = new Dictionary<string, object>()
                {
                    {nameof(RB_Assist.AssistName),model.AssistName.Trim() }
                };
                flag = assistRepository.Update(fileds, new WhereHelper(nameof(RB_Assist.AId), model.AId));
            }
            else
            {
                flag = assistRepository.Insert(model) > 0;
            }
            return flag;
        }

        /// <summary>
        /// 根据编号获取助教实体
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public RB_Assist GetAssistModule(object Id)
        {
            return assistRepository.GetEntity<RB_Assist>(Id);
        }
    }
}
