using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BLL { /// /// 模板 /// public class TemplateService { /// /// 根据主键获取模板 /// /// /// public static Model.SupportDocument_Template GetTemplateById(string templateId) { return Funs.DB.SupportDocument_Template.FirstOrDefault(e => e.TemplateId == templateId); } /// /// 添加 /// /// public static void AddTemplate(Model.SupportDocument_Template template) { Model.SupportDocument_Template newTemplate = new Model.SupportDocument_Template { TemplateId = template.TemplateId, Template = template.Template, UploadBy = template.UploadBy, UploadDate = template.UploadDate, AttachUrl = template.AttachUrl, }; Funs.DB.SupportDocument_Template.InsertOnSubmit(newTemplate); Funs.DB.SubmitChanges(); } /// /// 修改 /// /// public static void UpdateTemplate(Model.SupportDocument_Template template) { Model.SupportDocument_Template newTemplate = Funs.DB.SupportDocument_Template.FirstOrDefault(e => e.TemplateId == template.TemplateId); if (newTemplate!=null) { newTemplate.Template = template.Template; newTemplate.UploadBy = template.UploadBy; newTemplate.UploadDate = template.UploadDate; newTemplate.AttachUrl = template.AttachUrl; Funs.DB.SubmitChanges(); } } /// /// 根据主键删除 /// /// public static void DeleteTemplateById(string templateId) { Model.SupportDocument_Template template = Funs.DB.SupportDocument_Template.FirstOrDefault(e => e.TemplateId == templateId); if (template != null) { BLL.AttachFileService.DeleteAttachFile(Funs.RootPath, templateId, BLL.Const.TemplateMenuId);//删除附件 Funs.DB.SupportDocument_Template.DeleteOnSubmit(template); Funs.DB.SubmitChanges(); } } } }