namespace ISupply.BLL
|
{
|
public partial class WaterSupplyUnit
|
{
|
//Entity to GetModel
|
private Model.WaterSupplyUnit Entity2Model(Entity.WaterSupplyUnit entities)
|
{
|
if (entities == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.WaterSupplyUnit, Model.WaterSupplyUnit>()
|
.ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToList(src.Flags)))
|
).CreateMapper();
|
var model = mapper.Map<Entity.WaterSupplyUnit, Model.WaterSupplyUnit>(entities);
|
return model;
|
}
|
|
//Entities to GetModels
|
private List<Model.WaterSupplyUnit> Entity2Models(List<Entity.WaterSupplyUnit> entities)
|
{
|
if (entities == null || entities.Count() < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.WaterSupplyUnit, Model.WaterSupplyUnit>()
|
.ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToList(src.Flags)))
|
).CreateMapper();
|
var models = mapper.Map<List<Entity.WaterSupplyUnit>, List<Model.WaterSupplyUnit>>(entities);
|
return models;
|
}
|
|
//Model to Entity
|
private Entity.WaterSupplyUnit Model2Entity(Model.WaterSupplyUnit model)
|
{
|
if (model == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.WaterSupplyUnit, Entity.WaterSupplyUnit>()
|
.ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags)))
|
).CreateMapper();
|
var entities = mapper.Map<Model.WaterSupplyUnit, Entity.WaterSupplyUnit>(model);
|
return entities;
|
}
|
|
//Models to Entities
|
private List<Entity.WaterSupplyUnit> Model2Entities(List<Model.WaterSupplyUnit> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.WaterSupplyUnit, Entity.WaterSupplyUnit>()
|
.ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags)))
|
).CreateMapper();
|
var entities = mapper.Map<List<Model.WaterSupplyUnit>, List<Entity.WaterSupplyUnit>>(models);
|
return entities;
|
}
|
|
//Model to Entity
|
private void Model2Entity(Model.WaterSupplyUnit model, Entity.WaterSupplyUnit entities)
|
{
|
if (model == null || entities == null)
|
return;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.WaterSupplyUnit, Entity.WaterSupplyUnit>()
|
.ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags)))
|
).CreateMapper();
|
mapper.Map(model, entities);
|
}
|
}
|
}
|