using AutoMapper;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using IStation.Untity;
|
|
namespace IStation.Service
|
{
|
public partial class ProductInspectionContentItem
|
{
|
//Entity to GetModel
|
private Model.ProductInspectionContentItem Entity2Model(Entity.ProductInspectionContentItem entity)
|
{
|
if (entity == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ProductInspectionContentItem, Model.ProductInspectionContentItem>()
|
//.ForMember(d => d.DesignParas, opt => opt.MapFrom(src => Model.ProductInspectionContentItem.DesignParameters.ToModel(src.DesignParas)))
|
).CreateMapper();
|
var model = mapper.Map<Entity.ProductInspectionContentItem, Model.ProductInspectionContentItem>(entity);
|
return model;
|
}
|
//Entities to GetModels
|
private List<Model.ProductInspectionContentItem> Entity2Models(List<Entity.ProductInspectionContentItem> entities)
|
{
|
if (entities == null || entities.Count() < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ProductInspectionContentItem, Model.ProductInspectionContentItem>()
|
// .ForMember(d => d.DesignParas, opt => opt.MapFrom(src => Model.ProductInspectionContentItem.DesignParameters.ToModel(src.DesignParas)))
|
).CreateMapper();
|
var models = mapper.Map<List<Entity.ProductInspectionContentItem>, List<Model.ProductInspectionContentItem>>(entities);
|
return models;
|
}
|
|
//Model to Entity
|
private Entity.ProductInspectionContentItem Model2Entity(Model.ProductInspectionContentItem model)
|
{
|
if (model == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductInspectionContentItem, Entity.ProductInspectionContentItem>()
|
// .ForMember(d => d.DesignParas, opt => opt.MapFrom(src => src.DesignParas.ToJson()))
|
).CreateMapper();
|
var entity = mapper.Map<Model.ProductInspectionContentItem, Entity.ProductInspectionContentItem>(model);
|
return entity;
|
}
|
|
//Models to Entities
|
private List<Entity.ProductInspectionContentItem> Model2Entities(List<Model.ProductInspectionContentItem> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductInspectionContentItem, Entity.ProductInspectionContentItem>()
|
// .ForMember(d => d.DesignParas, opt => opt.MapFrom(src => src.DesignParas.ToJson()))
|
).CreateMapper();
|
var entities = mapper.Map<List<Model.ProductInspectionContentItem>, List<Entity.ProductInspectionContentItem>>(models);
|
return entities;
|
}
|
|
//Model to Entity
|
private void Model2Entity(Model.ProductInspectionContentItem model, Entity.ProductInspectionContentItem entity)
|
{
|
if (model == null || entity == null)
|
return;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductInspectionContentItem, Entity.ProductInspectionContentItem>()
|
// .ForMember(d => d.DesignParas, opt => opt.MapFrom(src => src.DesignParas.ToJson()))
|
).CreateMapper();
|
mapper.Map(model, entity);
|
}
|
|
//Models to Entities
|
private List<Entity.ProductInspectionContentValue> Model2Entities(List<Model.ProductInspectionContentValue> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductInspectionContentValue, Entity.ProductInspectionContentValue>()
|
// .ForMember(d => d.DesignParas, opt => opt.MapFrom(src => src.DesignParas.ToJson()))
|
).CreateMapper();
|
var entities = mapper.Map<List<Model.ProductInspectionContentValue>, List<Entity.ProductInspectionContentValue>>(models);
|
return entities;
|
}
|
|
|
|
}
|
}
|