using AutoMapper;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Service
|
{
|
public partial class PumpCurveExMapping
|
{
|
private Entity.PumpCurve Model2CurveEntity(Model.PumpCurveExMapping model)
|
{
|
if (model == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.PumpCurveExMapping, Entity.PumpCurve>()
|
.ForMember(d => d.CoordParas, opt => opt.MapFrom(src => src.CoordParas == null ? string.Empty : src.CoordParas.ToJson()))
|
.ForMember(d => d.CurveInfo, opt => opt.MapFrom(src => src.CurveInfo == null ? string.Empty : src.CurveInfo.ToDsString()))
|
.ForMember(d => d.PointInfo, opt => opt.MapFrom(src => src.PointInfo == null ? string.Empty : src.PointInfo.ToDsString()))
|
).CreateMapper();
|
var entity = mapper.Map<Model.PumpCurveExMapping, Entity.PumpCurve>(model);
|
return entity;
|
}
|
|
private Entity.PumpCurveMapping Model2MappingEntity(Model.PumpCurveExMapping model)
|
{
|
if (model == null)
|
return default;
|
var entity = new Entity.PumpCurveMapping();
|
entity.ID = model.MappingID;
|
entity.CorpID = model.CorpID;
|
entity.PumpID = model.PumpID;
|
entity.CurveID = model.ID;
|
entity.SortCode = model.SortCode;
|
entity.IsWorking = model.IsWorking;
|
return entity;
|
}
|
|
//组合
|
private List<Model.PumpCurveExMapping> Combine(IEnumerable<Model.PumpCurveMapping> mapping_list, IEnumerable<Model.PumpCurve> curve_list)
|
{
|
if (mapping_list == null || mapping_list.Count() < 1)
|
return default;
|
if (curve_list == null || curve_list.Count() < 1)
|
return default;
|
var vm_list = new List<Model.PumpCurveExMapping>();
|
foreach (var mapping in mapping_list)
|
{
|
var curve = curve_list.FirstOrDefault(x => x.ID == mapping.CurveID);
|
if (curve != null)
|
{
|
var vm = new Model.PumpCurveExMapping(curve, mapping);
|
vm_list.Add(vm);
|
}
|
}
|
return vm_list;
|
}
|
|
//组合
|
private List<Model.PumpCurveExMapping> Combine(Model.PumpCurve curve,IEnumerable<Model.PumpCurveMapping> mapping_list)
|
{
|
if (mapping_list == null || mapping_list.Count() < 1)
|
return default;
|
if (curve == null)
|
return default;
|
var vm_list = new List<Model.PumpCurveExMapping>();
|
foreach (var mapping in mapping_list)
|
{
|
if (mapping.CurveID == curve.ID)
|
{
|
var vm = new Model.PumpCurveExMapping(curve, mapping);
|
vm_list.Add(vm);
|
}
|
}
|
return vm_list;
|
}
|
|
|
|
}
|
}
|