using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
///
/// 开车安全线路图
///
public static class RoadMapService
{
///
/// 根据主键获取开车安全线路图
///
///
///
public static Model.DriverHse_RoadMap GetRoadMapById(string roadMapId)
{
return Funs.DB.DriverHse_RoadMap.FirstOrDefault(e => e.RoadMapId == roadMapId);
}
///
/// 添加开车安全线路图
///
///
public static void AddRoadMap(Model.DriverHse_RoadMap roadMap)
{
Model.DriverHse_RoadMap newRoadMap = new Model.DriverHse_RoadMap();
newRoadMap.RoadMapId = roadMap.RoadMapId;
newRoadMap.ProjectId = roadMap.ProjectId;
newRoadMap.Code = roadMap.Code;
newRoadMap.UnitWorkId = roadMap.UnitWorkId;
newRoadMap.CarArea = roadMap.CarArea;
newRoadMap.AttachUrl = roadMap.AttachUrl;
newRoadMap.Remark = roadMap.Remark;
Funs.DB.DriverHse_RoadMap.InsertOnSubmit(newRoadMap);
Funs.DB.SubmitChanges();
}
///
/// 修改开车安全线路图
///
///
public static void UpdateRoadMap(Model.DriverHse_RoadMap roadMap)
{
Model.DriverHse_RoadMap newRoadMap = Funs.DB.DriverHse_RoadMap.FirstOrDefault(e => e.RoadMapId == roadMap.RoadMapId);
if (newRoadMap != null)
{
newRoadMap.ProjectId = roadMap.ProjectId;
newRoadMap.Code = roadMap.Code;
newRoadMap.UnitWorkId = roadMap.UnitWorkId;
newRoadMap.CarArea = roadMap.CarArea;
newRoadMap.AttachUrl = roadMap.AttachUrl;
newRoadMap.Remark = roadMap.Remark;
Funs.DB.SubmitChanges();
}
}
///
/// 根据主键删除开车安全线路图
///
///
public static void DeleteRoadMapById(string roadMapId)
{
Model.DriverHse_RoadMap newRoadMap = Funs.DB.DriverHse_RoadMap.FirstOrDefault(e => e.RoadMapId == roadMapId);
if (newRoadMap != null)
{
if (!string.IsNullOrEmpty(newRoadMap.AttachUrl))
{
UploadAttachmentService.DeleteFile(Funs.RootPath, newRoadMap.AttachUrl);
}
Funs.DB.DriverHse_RoadMap.DeleteOnSubmit(newRoadMap);
Funs.DB.SubmitChanges();
}
}
}
}