namespace Yw.Service
|
{
|
public partial class HealthIndex
|
{
|
//Entity to Model
|
private static Model.HealthIndex Entity2Model(Entity.HealthIndex entity)
|
{
|
if (entity == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.HealthIndex, Model.HealthIndex>()).CreateMapper();
|
var model = mapper.Map<Entity.HealthIndex, Model.HealthIndex>(entity);
|
return model;
|
}
|
|
//Entities to Models
|
private static List<Model.HealthIndex> Entity2Models(List<Entity.HealthIndex> entities)
|
{
|
if (entities == null || entities.Count() < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.HealthIndex, Model.HealthIndex>()).CreateMapper();
|
var models = mapper.Map<List<Entity.HealthIndex>, List<Model.HealthIndex>>(entities);
|
return models;
|
}
|
|
//Model to Entity
|
private static Entity.HealthIndex Model2Entity(Model.HealthIndex model)
|
{
|
if (model == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.HealthIndex, Entity.HealthIndex>()).CreateMapper();
|
var entity = mapper.Map<Model.HealthIndex, Entity.HealthIndex>(model);
|
return entity;
|
}
|
|
//Models to Entities
|
private static List<Entity.HealthIndex> Model2Entities(List<Model.HealthIndex> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.HealthIndex, Entity.HealthIndex>()).CreateMapper();
|
var entities = mapper.Map<List<Model.HealthIndex>, List<Entity.HealthIndex>>(models);
|
return entities;
|
}
|
|
//Model to Entity
|
private static void Model2Entity(Model.HealthIndex model, Entity.HealthIndex entity)
|
{
|
if (model == null || entity == null)
|
return;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.HealthIndex, Entity.HealthIndex>()).CreateMapper();
|
mapper.Map(model, entity);
|
}
|
|
}
|
}
|