using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BLL { /// /// 试车管理 /// public static class TestRunService { /// /// 根据主键获取试车管理 /// /// /// public static Model.Driver_TestRun GetTestRunById(string testRunId) { return Funs.DB.Driver_TestRun.FirstOrDefault(e => e.TestRunId == testRunId); } /// /// 添加试车管理 /// /// public static void AddTestRun(Model.Driver_TestRun testRun) { Model.Driver_TestRun newTestRun = new Model.Driver_TestRun(); newTestRun.TestRunId = testRun.TestRunId; newTestRun.ProjectId = testRun.ProjectId; newTestRun.Code = testRun.Code; newTestRun.UnitWorkId = testRun.UnitWorkId; newTestRun.InstallationHead = testRun.InstallationHead; newTestRun.WorkContents = testRun.WorkContents; newTestRun.StartDate = testRun.StartDate; newTestRun.EndDate = testRun.EndDate; newTestRun.Descriptions = testRun.Descriptions; newTestRun.ProblemsAndSolutions = testRun.ProblemsAndSolutions; newTestRun.AttachUrl = testRun.AttachUrl; newTestRun.Remark = testRun.Remark; Funs.DB.Driver_TestRun.InsertOnSubmit(newTestRun); Funs.DB.SubmitChanges(); } /// /// 修改试车管理 /// /// public static void UpdateTestRun(Model.Driver_TestRun testRun) { Model.Driver_TestRun newTestRun = Funs.DB.Driver_TestRun.FirstOrDefault(e => e.TestRunId == testRun.TestRunId); if (newTestRun != null) { newTestRun.Code = testRun.Code; newTestRun.UnitWorkId = testRun.UnitWorkId; newTestRun.InstallationHead = testRun.InstallationHead; newTestRun.WorkContents = testRun.WorkContents; newTestRun.StartDate = testRun.StartDate; newTestRun.EndDate = testRun.EndDate; newTestRun.Descriptions = testRun.Descriptions; newTestRun.ProblemsAndSolutions = testRun.ProblemsAndSolutions; newTestRun.AttachUrl = testRun.AttachUrl; newTestRun.Remark = testRun.Remark; Funs.DB.SubmitChanges(); } } /// /// 根据主键删除试车管理 /// /// public static void DeleteTestRunById(string testRunId) { Model.Driver_TestRun newTestRun = Funs.DB.Driver_TestRun.FirstOrDefault(e => e.TestRunId == testRunId); if (newTestRun != null) { if (!string.IsNullOrEmpty(newTestRun.AttachUrl)) { UploadAttachmentService.DeleteFile(Funs.RootPath, newTestRun.AttachUrl); } Funs.DB.Driver_TestRun.DeleteOnSubmit(newTestRun); Funs.DB.SubmitChanges(); } } } }