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