using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 员工谈话记录
    /// 
    public class EmployeeConversationRecordService
    {
        /// 
        /// 根据主键获取员工谈话记录
        /// 
        /// 
        /// 
        public static Model.Party_EmployeeConversationRecord GetEmployeeConversationRecordById(string employeeConversationRecordId)
        {
            return Funs.DB.Party_EmployeeConversationRecord.FirstOrDefault(e => e.EmployeeConversationRecordId == employeeConversationRecordId);
        }
        /// 
        /// 添加员工谈话记录
        /// 
        /// 
        public static void AddEmployeeConversationRecord(Model.Party_EmployeeConversationRecord employeeConversationRecord)
        {
            Model.Party_EmployeeConversationRecord newEmployeeConversationRecord = new Model.Party_EmployeeConversationRecord
            {
                EmployeeConversationRecordId = employeeConversationRecord.EmployeeConversationRecordId,
                Year = employeeConversationRecord.Year,
                Speaker = employeeConversationRecord.Speaker,
                Interviewee = employeeConversationRecord.Interviewee,
                ConversationDate = employeeConversationRecord.ConversationDate,
                CompileMan = employeeConversationRecord.CompileMan,
                CompileDate = employeeConversationRecord.CompileDate
            };
            Funs.DB.Party_EmployeeConversationRecord.InsertOnSubmit(newEmployeeConversationRecord);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改员工谈话记录
        /// 
        /// 
        public static void UpdateEmployeeConversationRecord(Model.Party_EmployeeConversationRecord employeeConversationRecord)
        {
            Model.Party_EmployeeConversationRecord newEmployeeConversationRecord = Funs.DB.Party_EmployeeConversationRecord.FirstOrDefault(e => e.EmployeeConversationRecordId == employeeConversationRecord.EmployeeConversationRecordId);
            if (newEmployeeConversationRecord != null)
            {
                newEmployeeConversationRecord.Speaker = employeeConversationRecord.Speaker;
                newEmployeeConversationRecord.Interviewee = employeeConversationRecord.Interviewee;
                newEmployeeConversationRecord.ConversationDate = employeeConversationRecord.ConversationDate;
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除员工谈话记录
        /// 
        /// 
        public static void DeleteEmployeeConversationRecordById(string employeeConversationRecordId)
        {
            Model.Party_EmployeeConversationRecord employeeConversationRecord = Funs.DB.Party_EmployeeConversationRecord.FirstOrDefault(e => e.EmployeeConversationRecordId == employeeConversationRecordId);
            if (employeeConversationRecord != null)
            {
                CommonService.DeleteAttachFileById(employeeConversationRecordId);
                Funs.DB.Party_EmployeeConversationRecord.DeleteOnSubmit(employeeConversationRecord);
                Funs.DB.SubmitChanges();
            }
        }
    }
}