using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 其他巡检记录管理
    /// 
    public static class PropertyRunOthersCheckService
    {
        /// 
        /// 根据主键获取其他巡检记录管理信息
        /// 
        /// 
        /// 
        public static Model.ProduceProperty_PropertyRunOthersCheck GetPropertyRunOthersCheckById(string PropertyRunOthersCheckId)
        {
            return Funs.DB.ProduceProperty_PropertyRunOthersCheck.FirstOrDefault(e => e.PropertyRunOthersCheckId == PropertyRunOthersCheckId);
        }
        /// 
        /// 添加其他巡检记录管理信息
        /// 
        /// 
        public static void AddPropertyRunOthersCheck(Model.ProduceProperty_PropertyRunOthersCheck PropertyRunOthersCheck)
        {
            Model.ProduceProperty_PropertyRunOthersCheck newPropertyRunOthersCheck = new Model.ProduceProperty_PropertyRunOthersCheck();
            newPropertyRunOthersCheck.PropertyRunOthersCheckId = PropertyRunOthersCheck.PropertyRunOthersCheckId;
            newPropertyRunOthersCheck.ProjectId = PropertyRunOthersCheck.ProjectId;
            newPropertyRunOthersCheck.Code = PropertyRunOthersCheck.Code;
            newPropertyRunOthersCheck.UnitWorkId = PropertyRunOthersCheck.UnitWorkId;
            newPropertyRunOthersCheck.InstallationMan = PropertyRunOthersCheck.InstallationMan;
            newPropertyRunOthersCheck.RecordName = PropertyRunOthersCheck.RecordName;
            newPropertyRunOthersCheck.RecordCode = PropertyRunOthersCheck.RecordCode;
            newPropertyRunOthersCheck.RecordMan = PropertyRunOthersCheck.RecordMan;
            newPropertyRunOthersCheck.StartDate = PropertyRunOthersCheck.StartDate;
            newPropertyRunOthersCheck.EndDate = PropertyRunOthersCheck.EndDate;
            newPropertyRunOthersCheck.RecordInstructions = PropertyRunOthersCheck.RecordInstructions;
            newPropertyRunOthersCheck.ProblemsSolutions = PropertyRunOthersCheck.ProblemsSolutions;
            newPropertyRunOthersCheck.AttachUrl = PropertyRunOthersCheck.AttachUrl;
            newPropertyRunOthersCheck.Remark = PropertyRunOthersCheck.Remark;
            newPropertyRunOthersCheck.Profession = PropertyRunOthersCheck.Profession;
            Funs.DB.ProduceProperty_PropertyRunOthersCheck.InsertOnSubmit(newPropertyRunOthersCheck);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改其他巡检记录管理
        /// 
        /// 
        public static void UpdatePropertyRunOthersCheck(Model.ProduceProperty_PropertyRunOthersCheck PropertyRunOthersCheck)
        {
            Model.ProduceProperty_PropertyRunOthersCheck newPropertyRunOthersCheck = Funs.DB.ProduceProperty_PropertyRunOthersCheck.FirstOrDefault(e => e.PropertyRunOthersCheckId == PropertyRunOthersCheck.PropertyRunOthersCheckId);
            if (newPropertyRunOthersCheck != null)
            {
                newPropertyRunOthersCheck.Code = PropertyRunOthersCheck.Code;
                newPropertyRunOthersCheck.UnitWorkId = PropertyRunOthersCheck.UnitWorkId;
                newPropertyRunOthersCheck.InstallationMan = PropertyRunOthersCheck.InstallationMan;
                newPropertyRunOthersCheck.RecordName = PropertyRunOthersCheck.RecordName;
                newPropertyRunOthersCheck.RecordCode = PropertyRunOthersCheck.RecordCode;
                //newPropertyRunOthersCheck.RecordMan = PropertyRunOthersCheck.RecordMan;
                newPropertyRunOthersCheck.StartDate = PropertyRunOthersCheck.StartDate;
                newPropertyRunOthersCheck.EndDate = PropertyRunOthersCheck.EndDate;
                newPropertyRunOthersCheck.RecordInstructions = PropertyRunOthersCheck.RecordInstructions;
                newPropertyRunOthersCheck.ProblemsSolutions = PropertyRunOthersCheck.ProblemsSolutions;
                newPropertyRunOthersCheck.AttachUrl = PropertyRunOthersCheck.AttachUrl;
                newPropertyRunOthersCheck.Remark = PropertyRunOthersCheck.Remark;
                newPropertyRunOthersCheck.Profession = PropertyRunOthersCheck.Profession;
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除其他巡检记录管理
        /// 
        /// 
        public static void DeletePropertyRunOthersCheck(string PropertyRunOthersCheckId)
        {
            Model.ProduceProperty_PropertyRunOthersCheck PropertyRunOthersCheck = Funs.DB.ProduceProperty_PropertyRunOthersCheck.FirstOrDefault(e => e.PropertyRunOthersCheckId == PropertyRunOthersCheckId);
            if (PropertyRunOthersCheck != null)
            {
                if (!string.IsNullOrEmpty(PropertyRunOthersCheck.AttachUrl))
                {
                    BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, PropertyRunOthersCheck.AttachUrl);//删除附件
                }
                Funs.DB.ProduceProperty_PropertyRunOthersCheck.DeleteOnSubmit(PropertyRunOthersCheck);
                Funs.DB.SubmitChanges();
            }
        }
    }
}