using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 本年度党建工作计划
    /// 
    public class WorkPlanService
    {
        /// 
        /// 根据主键获取本年度党建工作计划
        /// 
        /// 
        /// 
        public static Model.Party_WorkPlan GetWorkPlanById(string workPlanId)
        {
            return Funs.DB.Party_WorkPlan.FirstOrDefault(e => e.WorkPlanId == workPlanId);
        }
        /// 
        /// 添加本年度党建工作计划
        /// 
        /// 
        public static void AddWorkPlan(Model.Party_WorkPlan workPlan)
        {
            Model.Party_WorkPlan newWorkPlan = new Model.Party_WorkPlan
            {
                WorkPlanId = workPlan.WorkPlanId,
                Year = workPlan.Year,
                CompileMan = workPlan.CompileMan,
                CompileDate = workPlan.CompileDate
            };
            Funs.DB.Party_WorkPlan.InsertOnSubmit(newWorkPlan);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改本年度党建工作计划
        /// 
        /// 
        public static void UpdateWorkPlan(Model.Party_WorkPlan workPlan)
        {
            Model.Party_WorkPlan newWorkPlan = Funs.DB.Party_WorkPlan.FirstOrDefault(e => e.WorkPlanId == workPlan.WorkPlanId);
            if (newWorkPlan != null)
            {
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除本年度党建工作计划
        /// 
        /// 
        public static void DeleteWorkPlanById(string workPlanId)
        {
            Model.Party_WorkPlan workPlan = Funs.DB.Party_WorkPlan.FirstOrDefault(e => e.WorkPlanId == workPlanId);
            if (workPlan != null)
            {
                CommonService.DeleteAttachFileById(workPlanId);
                Funs.DB.Party_WorkPlan.DeleteOnSubmit(workPlan);
                Funs.DB.SubmitChanges();
            }
        }
    }
}