using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 集中学习
    /// 
    public class FocusLearnService
    {
        /// 
        /// 根据主键获取集中学习
        /// 
        /// 
        /// 
        public static Model.Party_FocusLearn GetFocusLearnById(string focusLearnId)
        {
            return Funs.DB.Party_FocusLearn.FirstOrDefault(e => e.FocusLearnId == focusLearnId);
        }
        /// 
        /// 添加集中学习
        /// 
        /// 
        public static void AddFocusLearn(Model.Party_FocusLearn focusLearn)
        {
            Model.Party_FocusLearn newFocusLearn = new Model.Party_FocusLearn
            {
                FocusLearnId = focusLearn.FocusLearnId,
                Year = focusLearn.Year,
                Quarter = focusLearn.Quarter,
                CompileMan = focusLearn.CompileMan,
                CompileDate = focusLearn.CompileDate
            };
            Funs.DB.Party_FocusLearn.InsertOnSubmit(newFocusLearn);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改集中学习
        /// 
        /// 
        public static void UpdateFocusLearn(Model.Party_FocusLearn focusLearn)
        {
            Model.Party_FocusLearn newFocusLearn = Funs.DB.Party_FocusLearn.FirstOrDefault(e => e.FocusLearnId == focusLearn.FocusLearnId);
            if (newFocusLearn != null)
            {
                newFocusLearn.Quarter = focusLearn.Quarter;
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除集中学习
        /// 
        /// 
        public static void DeleteFocusLearnById(string focusLearnId)
        {
            Model.Party_FocusLearn focusLearn = Funs.DB.Party_FocusLearn.FirstOrDefault(e => e.FocusLearnId == focusLearnId);
            if (focusLearn != null)
            {
                CommonService.DeleteAttachFileById(focusLearnId);
                CommonService.DeleteAttachFileById(focusLearnId + "2");
                CommonService.DeleteAttachFileById(focusLearnId + "3");
                Funs.DB.Party_FocusLearn.DeleteOnSubmit(focusLearn);
                Funs.DB.SubmitChanges();
            }
        }
    }
}