using System;
|
using System.Data;
|
using System.Collections.Generic;
|
|
using System.Linq;
|
using AutoMapper;
|
|
namespace IStation.Service
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class InspectRecordFile
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public InspectRecordFile()
|
{
|
|
}
|
|
|
/// <summary>
|
/// /
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public long Add(IStation.Model.InspectRecordFile model)
|
{
|
if (model == null)
|
return 0;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.InspectRecordFile, Entity.InspectRecordFile>()
|
.ForMember(d => d.FileType, opt => opt.MapFrom(src => (int)src.FileType))
|
).CreateMapper();
|
var entity = mapper.Map<Model.InspectRecordFile, Entity.InspectRecordFile>(model);
|
|
IStation.DAL.InspectRecordFile calRepairInfo = new IStation.DAL.InspectRecordFile();
|
entity.UploadTime = DateTime.Now ;
|
return calRepairInfo.Insert(entity);
|
}
|
|
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="ID"></param>
|
/// <returns></returns>
|
public IStation.Model.InspectRecordFile GetByFileID(long ID)
|
{
|
return Entity2Model(new IStation.DAL.InspectRecordFile().GetByID(ID));
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="RecordID"></param>
|
/// <returns></returns>
|
public List<IStation.Model.InspectRecordFile> GetByRecordID(long RecordID)
|
{
|
IStation.DAL.InspectRecordFile calRepairInfo = new IStation.DAL.InspectRecordFile();
|
var list = calRepairInfo.GetByRecordID(RecordID);
|
return Entity2Model(list);
|
}
|
|
|
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="entities"></param>
|
/// <returns></returns>
|
private static List<Model.InspectRecordFile> Entity2Model(IEnumerable<Entity.InspectRecordFile> entities)
|
{
|
if (entities == null || entities.Count() < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.InspectRecordFile, Model.InspectRecordFile>()
|
//.ForMember(d => d.MapPosition, opt => opt.MapFrom(src => Model.Map.PointInfo.ToModel(src.MapPosition)))
|
//.ForMember(d => d.GisPosition, opt => opt.MapFrom(src => Model.Gis.PointInfo.ToModel(src.GisPosition)))
|
).CreateMapper();
|
var models = mapper.Map<IEnumerable<Entity.InspectRecordFile>, List<Model.InspectRecordFile>>(entities);
|
return models;
|
}
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="entities"></param>
|
/// <returns></returns>
|
private static Model.InspectRecordFile Entity2Model(Entity.InspectRecordFile entities)
|
{
|
if (entities == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.InspectRecordFile, Model.InspectRecordFile>()
|
//.ForMember(d => d.MapPosition, opt => opt.MapFrom(src => Model.Map.PointInfo.ToModel(src.MapPosition)))
|
//.ForMember(d => d.GisPosition, opt => opt.MapFrom(src => Model.Gis.PointInfo.ToModel(src.GisPosition)))
|
).CreateMapper();
|
var model = mapper.Map<Entity.InspectRecordFile, Model.InspectRecordFile>(entities);
|
return model;
|
}
|
|
|
}
|
}
|