| | |
| | | namespace HStation.Service |
| | | { |
| | | public partial class ValveSeries |
| | | public partial class AssetsValveSeries |
| | | { |
| | | //Entity to GetModel |
| | | internal static Model.ValveSeries Entity2Model(Entity.ValveSeries entity) |
| | | internal static Model.AssetsValveSeries Entity2Model(Entity.AssetsValveSeries entity) |
| | | { |
| | | if (entity == null) |
| | | return default; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ValveSeries, Model.ValveSeries>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AssetsValveSeries, Model.AssetsValveSeries>() |
| | | .ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToDictionary(src.Paras))) |
| | | .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToList(src.Flags))) |
| | | ).CreateMapper(); |
| | | var model = mapper.Map<Entity.ValveSeries, Model.ValveSeries>(entity); |
| | | var model = mapper.Map<Entity.AssetsValveSeries, Model.AssetsValveSeries>(entity); |
| | | return model; |
| | | } |
| | | |
| | | //Entities to GetModels |
| | | internal static List<Model.ValveSeries> Entity2Models(List<Entity.ValveSeries> entities) |
| | | internal static List<Model.AssetsValveSeries> Entity2Models(List<Entity.AssetsValveSeries> entities) |
| | | { |
| | | if (entities == null || entities.Count < 1) |
| | | return default; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ValveSeries, Model.ValveSeries>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AssetsValveSeries, Model.AssetsValveSeries>() |
| | | .ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToDictionary(src.Paras))) |
| | | .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToList(src.Flags))) |
| | | ).CreateMapper(); |
| | | var models = mapper.Map<List<Entity.ValveSeries>, List<Model.ValveSeries>>(entities); |
| | | var models = mapper.Map<List<Entity.AssetsValveSeries>, List<Model.AssetsValveSeries>>(entities); |
| | | return models; |
| | | } |
| | | |
| | | //Model to Entity |
| | | internal static Entity.ValveSeries Model2Entity(Model.ValveSeries model) |
| | | internal static Entity.AssetsValveSeries Model2Entity(Model.AssetsValveSeries model) |
| | | { |
| | | if (model == null) |
| | | return default; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ValveSeries, Entity.ValveSeries>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsValveSeries, Entity.AssetsValveSeries>() |
| | | .ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToString(src.Paras))) |
| | | .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags))) |
| | | ).CreateMapper(); |
| | | var entity = mapper.Map<Model.ValveSeries, Entity.ValveSeries>(model); |
| | | var entity = mapper.Map<Model.AssetsValveSeries, Entity.AssetsValveSeries>(model); |
| | | return entity; |
| | | } |
| | | |
| | | //Models to Entities |
| | | internal static List<Entity.ValveSeries> Model2Entities(List<Model.ValveSeries> models) |
| | | internal static List<Entity.AssetsValveSeries> Model2Entities(List<Model.AssetsValveSeries> models) |
| | | { |
| | | if (models == null || models.Count < 1) |
| | | return default; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ValveSeries, Entity.ValveSeries>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsValveSeries, Entity.AssetsValveSeries>() |
| | | .ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToString(src.Paras))) |
| | | .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags))) |
| | | ).CreateMapper(); |
| | | var entities = mapper.Map<List<Model.ValveSeries>, List<Entity.ValveSeries>>(models); |
| | | var entities = mapper.Map<List<Model.AssetsValveSeries>, List<Entity.AssetsValveSeries>>(models); |
| | | return entities; |
| | | } |
| | | |
| | | //Model to Entity |
| | | internal static void Model2Entity(Model.ValveSeries model, Entity.ValveSeries entity) |
| | | internal static void Model2Entity(Model.AssetsValveSeries model, Entity.AssetsValveSeries entity) |
| | | { |
| | | if (model == null || entity == null) |
| | | return; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ValveSeries, Entity.ValveSeries>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsValveSeries, Entity.AssetsValveSeries>() |
| | | ).CreateMapper(); |
| | | mapper.Map(model, entity); |
| | | } |