using AutoMapper;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
namespace IStation.BLL
|
{
|
public partial class PumpSpeedCurve
|
{
|
|
//Entity to GetModel
|
private Model.PumpSpeedCurve Entity2Model(Entity.PumpSpeedCurve entity)
|
{
|
if (entity == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.PumpSpeedCurve, Model.PumpSpeedCurve>()
|
.ForMember(d => d.CoordParas, opt => opt.MapFrom(src => Model.CurveCoordinateParas.ToModel(src.CoordParas)))
|
.ForMember(d => d.CurveInfo, opt => opt.MapFrom(src => Model.FeatCurveExpressGroup.ToModel(src.CurveInfo)))
|
//.ForMember(d => d.PointInfo, opt => opt.MapFrom(src => Model.FeatCurvePointGroup.ToModel(src.PointInfo)))
|
).CreateMapper();
|
var model = mapper.Map<Entity.PumpSpeedCurve, Model.PumpSpeedCurve>(entity);
|
return model;
|
}
|
|
//Entities to GetModels
|
private List<Model.PumpSpeedCurve> Entity2Models(List<Entity.PumpSpeedCurve> entities)
|
{
|
if (entities == null || entities.Count() < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.PumpSpeedCurve, Model.PumpSpeedCurve>()
|
.ForMember(d => d.CoordParas, opt => opt.MapFrom(src => Model.CurveCoordinateParas.ToModel(src.CoordParas)))
|
.ForMember(d => d.CurveInfo, opt => opt.MapFrom(src => Model.FeatCurveExpressGroup.ToModel(src.CurveInfo)))
|
// .ForMember(d => d.PointInfo, opt => opt.MapFrom(src => Model.FeatCurvePointGroup.ToModel(src.PointInfo)))
|
).CreateMapper();
|
var models = mapper.Map<List<Entity.PumpSpeedCurve>, List<Model.PumpSpeedCurve>>(entities);
|
return models;
|
}
|
|
//Model to Entity
|
private Entity.PumpSpeedCurve Model2Entity(Model.PumpSpeedCurve model)
|
{
|
if (model == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.PumpSpeedCurve, Entity.PumpSpeedCurve>()
|
.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.PumpSpeedCurve, Entity.PumpSpeedCurve>(model);
|
return entity;
|
}
|
|
//Models to Entities
|
private List<Entity.PumpSpeedCurve> Model2Entities(List<Model.PumpSpeedCurve> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.PumpSpeedCurve, Entity.PumpSpeedCurve>()
|
.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 entities = mapper.Map<List<Model.PumpSpeedCurve>, List<Entity.PumpSpeedCurve>>(models);
|
return entities;
|
}
|
|
//Model to Entity
|
private void Model2Entity(Model.PumpSpeedCurve model, Entity.PumpSpeedCurve entity)
|
{
|
if (model == null || entity == null)
|
return;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.PumpSpeedCurve, Entity.PumpSpeedCurve>()
|
.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();
|
mapper.Map(model, entity);
|
}
|
|
|
}
|
}
|