namespace HStation.Service
|
{
|
public partial class AssetsElbowMain
|
{
|
//Entity to GetModel
|
internal static Model.AssetsElbowMain Entity2Model(Entity.AssetsElbowMain entity)
|
{
|
if (entity == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AssetsElbowMain, Model.AssetsElbowMain>()
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => ToList(src.KeyWord)))
|
).CreateMapper();
|
var model = mapper.Map<Entity.AssetsElbowMain, Model.AssetsElbowMain>(entity);
|
return model;
|
}
|
|
//Entities to GetModels
|
internal static List<Model.AssetsElbowMain> Entity2Models(List<Entity.AssetsElbowMain> entities)
|
{
|
if (entities == null || entities.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AssetsElbowMain, Model.AssetsElbowMain>()
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => ToList(src.KeyWord)))
|
|
).CreateMapper();
|
var models = mapper.Map<List<Entity.AssetsElbowMain>, List<Model.AssetsElbowMain>>(entities);
|
return models;
|
}
|
|
//Model to Entity
|
internal static Entity.AssetsElbowMain Model2Entity(Model.AssetsElbowMain model)
|
{
|
if (model == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsElbowMain, Entity.AssetsElbowMain>()
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => ToString(src.KeyWord)))
|
).CreateMapper();
|
var entity = mapper.Map<Model.AssetsElbowMain, Entity.AssetsElbowMain>(model);
|
return entity;
|
}
|
|
//Models to Entities
|
internal static List<Entity.AssetsElbowMain> Model2Entities(List<Model.AssetsElbowMain> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsElbowMain, Entity.AssetsElbowMain>()
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => ToString(src.KeyWord)))
|
).CreateMapper();
|
var entities = mapper.Map<List<Model.AssetsElbowMain>, List<Entity.AssetsElbowMain>>(models);
|
return entities;
|
}
|
|
//Model to Entity
|
internal static void Model2Entity(Model.AssetsElbowMain model, Entity.AssetsElbowMain entity)
|
{
|
if (model == null || entity == null)
|
return;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsElbowMain, Entity.AssetsElbowMain>()
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => ToString(src.KeyWord)))
|
).CreateMapper();
|
mapper.Map(model, entity);
|
}
|
|
public static List<string> ToList(string keyword)
|
{
|
if (string.IsNullOrEmpty(keyword))
|
{
|
return new List<string>();
|
}
|
|
return keyword.Split(new string[1] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
}
|
|
public static string ToString(List<string> KeyWord)
|
{
|
if (KeyWord == null || KeyWord.Count < 1)
|
{
|
return string.Empty;
|
}
|
|
return string.Join(",", KeyWord);
|
}
|
}
|
}
|