using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 上年度党建工作总结
    /// 
    public class LastWorkSummaryService
    {
        /// 
        /// 根据主键获取上年度党建工作总结
        /// 
        /// 
        /// 
        public static Model.Party_LastWorkSummary GetLastWorkSummaryById(string lastWorkSummaryId)
        {
            return Funs.DB.Party_LastWorkSummary.FirstOrDefault(e => e.LastWorkSummaryId == lastWorkSummaryId);
        }
        /// 
        /// 添加上年度党建工作总结
        /// 
        /// 
        public static void AddLastWorkSummary(Model.Party_LastWorkSummary lastWorkSummary)
        {
            Model.Party_LastWorkSummary newLastWorkSummary = new Model.Party_LastWorkSummary
            {
                LastWorkSummaryId = lastWorkSummary.LastWorkSummaryId,
                Year = lastWorkSummary.Year,
                CompileMan = lastWorkSummary.CompileMan,
                CompileDate = lastWorkSummary.CompileDate
            };
            Funs.DB.Party_LastWorkSummary.InsertOnSubmit(newLastWorkSummary);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改上年度党建工作总结
        /// 
        /// 
        public static void UpdateLastWorkSummary(Model.Party_LastWorkSummary lastWorkSummary)
        {
            Model.Party_LastWorkSummary newLastWorkSummary = Funs.DB.Party_LastWorkSummary.FirstOrDefault(e => e.LastWorkSummaryId == lastWorkSummary.LastWorkSummaryId);
            if (newLastWorkSummary != null)
            {
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除上年度党建工作总结
        /// 
        /// 
        public static void DeleteLastWorkSummaryById(string lastWorkSummaryId)
        {
            Model.Party_LastWorkSummary lastWorkSummary = Funs.DB.Party_LastWorkSummary.FirstOrDefault(e => e.LastWorkSummaryId == lastWorkSummaryId);
            if (lastWorkSummary != null)
            {
                CommonService.DeleteAttachFileById(lastWorkSummaryId);
                Funs.DB.Party_LastWorkSummary.DeleteOnSubmit(lastWorkSummary);
                Funs.DB.SubmitChanges();
            }
        }
    }
}