namespace Yw.Service
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class RepairTaskForm
|
{
|
//Entity to Model
|
private Model.RepairTaskForm Entity2Model(Entity.RepairTaskForm entity)
|
{
|
if (entity == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.RepairTaskForm, Model.RepairTaskForm>()
|
.ForMember(d => d.Location, opt => opt.MapFrom(src => Model.Repair.Location.ToList(src.Location)))
|
).CreateMapper();
|
var model = mapper.Map<Entity.RepairTaskForm, Model.RepairTaskForm>(entity);
|
return model;
|
}
|
//Entities to Models
|
private List<Model.RepairTaskForm> Entity2Models(List<Entity.RepairTaskForm> entities)
|
{
|
if (entities == null || entities.Count() < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.RepairTaskForm, Model.RepairTaskForm>()
|
.ForMember(d => d.Location, opt => opt.MapFrom(src => Model.Repair.Location.ToList(src.Location)))
|
).CreateMapper();
|
var models = mapper.Map<List<Entity.RepairTaskForm>, List<Model.RepairTaskForm>>(entities);
|
return models;
|
}
|
|
//Model to Entity
|
private Entity.RepairTaskForm Model2Entity(Model.RepairTaskForm model)
|
{
|
if (model == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.RepairTaskForm, Entity.RepairTaskForm>()
|
.ForMember(d => d.Location, opt => opt.MapFrom(src => Model.Repair.Location.ToJson(src.Location)))
|
).CreateMapper();
|
var entity = mapper.Map<Model.RepairTaskForm, Entity.RepairTaskForm>(model);
|
return entity;
|
}
|
|
//Models to Entities
|
private List<Entity.RepairTaskForm> Model2Entities(List<Model.RepairTaskForm> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.RepairTaskForm, Entity.RepairTaskForm>()
|
.ForMember(d => d.Location, opt => opt.MapFrom(src => Model.Repair.Location.ToJson(src.Location)))
|
).CreateMapper();
|
var entities = mapper.Map<List<Model.RepairTaskForm>, List<Entity.RepairTaskForm>>(models);
|
return entities;
|
}
|
|
//Model to Entity
|
private void Model2Entity(Model.RepairTaskForm model, Entity.RepairTaskForm entity)
|
{
|
if (model == null || entity == null)
|
return;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.RepairTaskForm, Entity.RepairTaskForm>()
|
.ForMember(d => d.Location, opt => opt.MapFrom(src => Model.Repair.Location.ToJson(src.Location)))
|
).CreateMapper();
|
mapper.Map(model, entity);
|
}
|
|
//Entity to Model
|
private Model.RepairRequestForm Entity2Model(Entity.RepairRequestForm entity)
|
{
|
if (entity == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.RepairRequestForm, Model.RepairRequestForm>()
|
.ForMember(d => d.Location, opt => opt.MapFrom(src => Model.Repair.Location.ToList(src.Location)))
|
).CreateMapper();
|
var model = mapper.Map<Entity.RepairRequestForm, Model.RepairRequestForm>(entity);
|
return model;
|
}
|
|
//Models to Entities
|
private List<Entity.RepairTaskLogFile> Model2Entities(List<Model.RepairTaskLogFile> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.RepairTaskLogFile, Entity.RepairTaskLogFile>()
|
).CreateMapper();
|
var entities = mapper.Map<List<Model.RepairTaskLogFile>, List<Entity.RepairTaskLogFile>>(models);
|
return entities;
|
}
|
|
//Model to Entity
|
private void Model2Entity(Model.RepairTaskLogFile model, Entity.RepairTaskLogFile entity)
|
{
|
if (model == null || entity == null)
|
return;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.RepairTaskLogFile, Entity.RepairTaskLogFile>()
|
).CreateMapper();
|
mapper.Map(model, entity);
|
}
|
|
|
}
|
}
|