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