using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 机泵巡检记录管理
    /// 
    public static class PropertyRunPumpCheckService
    {
        /// 
        /// 根据主键获取机泵巡检记录管理信息
        /// 
        /// 
        /// 
        public static Model.ProduceProperty_PropertyRunPumpCheck GetPropertyRunPumpCheckById(string PropertyRunPumpCheckId)
        {
            return Funs.DB.ProduceProperty_PropertyRunPumpCheck.FirstOrDefault(e => e.PropertyRunPumpCheckId == PropertyRunPumpCheckId);
        }
        /// 
        /// 添加机泵巡检记录管理信息
        /// 
        /// 
        public static void AddPropertyRunPumpCheck(Model.ProduceProperty_PropertyRunPumpCheck PropertyRunPumpCheck)
        {
            Model.ProduceProperty_PropertyRunPumpCheck newPropertyRunPumpCheck = new Model.ProduceProperty_PropertyRunPumpCheck();
            newPropertyRunPumpCheck.PropertyRunPumpCheckId = PropertyRunPumpCheck.PropertyRunPumpCheckId;
            newPropertyRunPumpCheck.ProjectId = PropertyRunPumpCheck.ProjectId;
            newPropertyRunPumpCheck.Code = PropertyRunPumpCheck.Code;
            newPropertyRunPumpCheck.UnitWorkId = PropertyRunPumpCheck.UnitWorkId;
            newPropertyRunPumpCheck.InstallationMan = PropertyRunPumpCheck.InstallationMan;
            newPropertyRunPumpCheck.RecordName = PropertyRunPumpCheck.RecordName;
            newPropertyRunPumpCheck.RecordCode = PropertyRunPumpCheck.RecordCode;
            newPropertyRunPumpCheck.RecordMan = PropertyRunPumpCheck.RecordMan;
            newPropertyRunPumpCheck.StartDate = PropertyRunPumpCheck.StartDate;
            newPropertyRunPumpCheck.EndDate = PropertyRunPumpCheck.EndDate;
            newPropertyRunPumpCheck.RecordInstructions = PropertyRunPumpCheck.RecordInstructions;
            newPropertyRunPumpCheck.ProblemsSolutions = PropertyRunPumpCheck.ProblemsSolutions;
            newPropertyRunPumpCheck.AttachUrl = PropertyRunPumpCheck.AttachUrl;
            newPropertyRunPumpCheck.Remark = PropertyRunPumpCheck.Remark;
            Funs.DB.ProduceProperty_PropertyRunPumpCheck.InsertOnSubmit(newPropertyRunPumpCheck);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改机泵巡检记录管理
        /// 
        /// 
        public static void UpdatePropertyRunPumpCheck(Model.ProduceProperty_PropertyRunPumpCheck PropertyRunPumpCheck)
        {
            Model.ProduceProperty_PropertyRunPumpCheck newPropertyRunPumpCheck = Funs.DB.ProduceProperty_PropertyRunPumpCheck.FirstOrDefault(e => e.PropertyRunPumpCheckId == PropertyRunPumpCheck.PropertyRunPumpCheckId);
            if (newPropertyRunPumpCheck != null)
            {
                newPropertyRunPumpCheck.Code = PropertyRunPumpCheck.Code;
                newPropertyRunPumpCheck.UnitWorkId = PropertyRunPumpCheck.UnitWorkId;
                newPropertyRunPumpCheck.InstallationMan = PropertyRunPumpCheck.InstallationMan;
                newPropertyRunPumpCheck.RecordName = PropertyRunPumpCheck.RecordName;
                newPropertyRunPumpCheck.RecordCode = PropertyRunPumpCheck.RecordCode;
                // newPropertyRunPumpCheck.RecordMan = PropertyRunPumpCheck.RecordMan;
                newPropertyRunPumpCheck.StartDate = PropertyRunPumpCheck.StartDate;
                newPropertyRunPumpCheck.EndDate = PropertyRunPumpCheck.EndDate;
                newPropertyRunPumpCheck.RecordInstructions = PropertyRunPumpCheck.RecordInstructions;
                newPropertyRunPumpCheck.ProblemsSolutions = PropertyRunPumpCheck.ProblemsSolutions;
                newPropertyRunPumpCheck.AttachUrl = PropertyRunPumpCheck.AttachUrl;
                newPropertyRunPumpCheck.Remark = PropertyRunPumpCheck.Remark;
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除机泵巡检记录管理
        /// 
        /// 
        public static void DeletePropertyRunPumpCheck(string PropertyRunPumpCheckId)
        {
            Model.ProduceProperty_PropertyRunPumpCheck PropertyRunPumpCheck = Funs.DB.ProduceProperty_PropertyRunPumpCheck.FirstOrDefault(e => e.PropertyRunPumpCheckId == PropertyRunPumpCheckId);
            if (PropertyRunPumpCheck != null)
            {
                if (!string.IsNullOrEmpty(PropertyRunPumpCheck.AttachUrl))
                {
                    BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, PropertyRunPumpCheck.AttachUrl);//删除附件
                }
                Funs.DB.ProduceProperty_PropertyRunPumpCheck.DeleteOnSubmit(PropertyRunPumpCheck);
                Funs.DB.SubmitChanges();
            }
        }
    }
}