using AutoMapper;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Service
|
{
|
public partial class ParasConfigure
|
{
|
//Entity to Model
|
private Model.ParasConfigure Entity2Model(Entity.ParasConfigure entity)
|
{
|
if (entity == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ParasConfigure, Model.ParasConfigure>()).CreateMapper();
|
var model = mapper.Map<Entity.ParasConfigure, Model.ParasConfigure>(entity);
|
return model;
|
}
|
//Entities to Models
|
private List<Model.ParasConfigure> Entity2Models(List<Entity.ParasConfigure> entities)
|
{
|
if (entities == null || entities.Count() < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ParasConfigure, Model.ParasConfigure>()).CreateMapper();
|
var models = mapper.Map<List<Entity.ParasConfigure>, List<Model.ParasConfigure>>(entities);
|
return models;
|
}
|
|
//Model to Entity
|
private Entity.ParasConfigure Model2Entity(Model.ParasConfigure model)
|
{
|
if (model == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ParasConfigure, Entity.ParasConfigure>()).CreateMapper();
|
var entity = mapper.Map<Model.ParasConfigure, Entity.ParasConfigure>(model);
|
return entity;
|
}
|
|
//Models to Entities
|
private List<Entity.ParasConfigure> Model2Entities(List<Model.ParasConfigure> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ParasConfigure, Entity.ParasConfigure>()).CreateMapper();
|
var entities = mapper.Map<List<Model.ParasConfigure>, List<Entity.ParasConfigure>>(models);
|
return entities;
|
}
|
|
//Model to Entity
|
private void Model2Entity(Model.ParasConfigure model, Entity.ParasConfigure entity)
|
{
|
if (model == null || entity == null)
|
return;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ParasConfigure, Entity.ParasConfigure>()).CreateMapper();
|
mapper.Map(model, entity);
|
}
|
|
}
|
}
|