using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 民主评议党员
    /// 
    public class CommentPartyerService
    {
        /// 
        /// 根据主键获取民主评议党员
        /// 
        /// 
        /// 
        public static Model.Party_CommentPartyer GetCommentPartyerById(string commentPartyerId)
        {
            return Funs.DB.Party_CommentPartyer.FirstOrDefault(e => e.CommentPartyerId == commentPartyerId);
        }
        /// 
        /// 添加民主评议党员
        /// 
        /// 
        public static void AddCommentPartyer(Model.Party_CommentPartyer commentPartyer)
        {
            Model.Party_CommentPartyer newCommentPartyer = new Model.Party_CommentPartyer
            {
                CommentPartyerId = commentPartyer.CommentPartyerId,
                Year = commentPartyer.Year,
                ProjectId = commentPartyer.ProjectId,
                Partyers = commentPartyer.Partyers,
                Host=commentPartyer.Host,
                CompileMan = commentPartyer.CompileMan,
                CompileDate = commentPartyer.CompileDate
            };
            Funs.DB.Party_CommentPartyer.InsertOnSubmit(newCommentPartyer);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改民主评议党员
        /// 
        /// 
        public static void UpdateCommentPartyer(Model.Party_CommentPartyer commentPartyer)
        {
            Model.Party_CommentPartyer newCommentPartyer = Funs.DB.Party_CommentPartyer.FirstOrDefault(e => e.CommentPartyerId == commentPartyer.CommentPartyerId);
            if (newCommentPartyer != null)
            {
                newCommentPartyer.ProjectId = commentPartyer.ProjectId;
                newCommentPartyer.Partyers = commentPartyer.Partyers;
                newCommentPartyer.Host = commentPartyer.Host;
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除民主评议党员
        /// 
        /// 
        public static void DeleteCommentPartyerById(string commentPartyerId)
        {
            Model.Party_CommentPartyer commentPartyer = Funs.DB.Party_CommentPartyer.FirstOrDefault(e => e.CommentPartyerId == commentPartyerId);
            if (commentPartyer != null)
            {
                CommonService.DeleteAttachFileById(commentPartyerId);
                Funs.DB.Party_CommentPartyer.DeleteOnSubmit(commentPartyer);
                Funs.DB.SubmitChanges();
            }
        }
    }
}