﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tydeus.Data;
using Tydeus.Model;

namespace Tydeus.Business
{
    /// <summary>
    /// 教师业务类
    /// </summary>
    public class TeacherBusiness
    {
        #region Field
        /// <summary>
        /// 教师Repository
        /// </summary>
        TeacherRepository teacherRepository;
        #endregion //Field

        #region Constructor
        /// <summary>
        /// 教师业务类
        /// </summary>
        public TeacherBusiness()
        {
            this.teacherRepository = new TeacherRepository();
        }
        #endregion //Constructor

        #region Method
        /// <summary>
        /// 获取原始教师列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Tydeus.Model.SQL.Teacher> GetOriginList()
        {
            Tydeus.Data.SQL.TeacherRepository teacherRepository = new Data.SQL.TeacherRepository();
            return teacherRepository.GetList();
        }

        /// <summary>
        /// 根据代码获取教师
        /// </summary>
        /// <param name="code">教师代码</param>
        /// <returns></returns>
        public Teacher GetByCode(string code)
        {
            return this.teacherRepository.GetByCode(code);
        }

        /// <summary>
        /// 更新教师
        /// </summary>
        /// <param name="data">教师对象</param>
        /// <returns></returns>
        /// <remarks>对象整体更新，新建对象覆盖。</remarks>
        public ErrorCode Update(Teacher data)
        {
            return this.teacherRepository.Update(data);
        }

        /// <summary>
        /// 编辑教师
        /// </summary>
        /// <param name="data">教师对象</param>
        /// <returns></returns>
        /// <remarks>对象部分更新，仅编辑对象自身部分属性。</remarks>
        public ErrorCode Edit(Teacher data)
        {
            return this.teacherRepository.Update(data);
        }
        #endregion //Method
    }
}
