using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 支部党小组会
    /// 
    public class PartyMeetingService
    {
        /// 
        /// 根据主键获取支部党小组会
        /// 
        /// 
        /// 
        public static Model.Party_PartyMeeting GetPartyMeetingById(string partyMeetingId)
        {
            return Funs.DB.Party_PartyMeeting.FirstOrDefault(e => e.PartyMeetingId == partyMeetingId);
        }
        /// 
        /// 添加支部党小组会
        /// 
        /// 
        public static void AddPartyMeeting(Model.Party_PartyMeeting partyMeeting)
        {
            Model.Party_PartyMeeting newPartyMeeting = new Model.Party_PartyMeeting
            {
                PartyMeetingId = partyMeeting.PartyMeetingId,
                Year = partyMeeting.Year,
                Month = partyMeeting.Month,
                CompileMan = partyMeeting.CompileMan,
                CompileDate = partyMeeting.CompileDate
            };
            Funs.DB.Party_PartyMeeting.InsertOnSubmit(newPartyMeeting);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改支部党小组会
        /// 
        /// 
        public static void UpdatePartyMeeting(Model.Party_PartyMeeting partyMeeting)
        {
            Model.Party_PartyMeeting newPartyMeeting = Funs.DB.Party_PartyMeeting.FirstOrDefault(e => e.PartyMeetingId == partyMeeting.PartyMeetingId);
            if (newPartyMeeting != null)
            {
                newPartyMeeting.Month = partyMeeting.Month;
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除支部党小组会
        /// 
        /// 
        public static void DeletePartyMeetingById(string partyMeetingId)
        {
            Model.Party_PartyMeeting partyMeeting = Funs.DB.Party_PartyMeeting.FirstOrDefault(e => e.PartyMeetingId == partyMeetingId);
            if (partyMeeting != null)
            {
                CommonService.DeleteAttachFileById(partyMeetingId);
                CommonService.DeleteAttachFileById(partyMeetingId + "2");
                CommonService.DeleteAttachFileById(partyMeetingId + "3");
                Funs.DB.Party_PartyMeeting.DeleteOnSubmit(partyMeeting);
                Funs.DB.SubmitChanges();
            }
        }
    }
}