| | |
| | | namespace HStation.Service |
| | | { |
| | | public partial class PumpGroup |
| | | public partial class AssetsPumpGroup |
| | | { |
| | | //Entity to GetModel |
| | | internal static Model.PumpGroup Entity2Model(Entity.PumpGroup entity) |
| | | internal static Model.AssetsPumpGroup Entity2Model(Entity.AssetsPumpGroup entity) |
| | | { |
| | | if (entity == null) |
| | | return default; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.PumpGroup, Model.PumpGroup>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AssetsPumpGroup, Model.AssetsPumpGroup>() |
| | | .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.PumpGroup, Model.PumpGroup>(entity); |
| | | var model = mapper.Map<Entity.AssetsPumpGroup, Model.AssetsPumpGroup>(entity); |
| | | return model; |
| | | } |
| | | |
| | | //Entities to GetModels |
| | | internal static List<Model.PumpGroup> Entity2Models(List<Entity.PumpGroup> entities) |
| | | internal static List<Model.AssetsPumpGroup> Entity2Models(List<Entity.AssetsPumpGroup> entities) |
| | | { |
| | | if (entities == null || entities.Count < 1) |
| | | return default; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.PumpGroup, Model.PumpGroup>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AssetsPumpGroup, Model.AssetsPumpGroup>() |
| | | .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.PumpGroup>, List<Model.PumpGroup>>(entities); |
| | | var models = mapper.Map<List<Entity.AssetsPumpGroup>, List<Model.AssetsPumpGroup>>(entities); |
| | | return models; |
| | | } |
| | | |
| | | //Model to Entity |
| | | internal static Entity.PumpGroup Model2Entity(Model.PumpGroup model) |
| | | internal static Entity.AssetsPumpGroup Model2Entity(Model.AssetsPumpGroup model) |
| | | { |
| | | if (model == null) |
| | | return default; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.PumpGroup, Entity.PumpGroup>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsPumpGroup, Entity.AssetsPumpGroup>() |
| | | .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.PumpGroup, Entity.PumpGroup>(model); |
| | | var entity = mapper.Map<Model.AssetsPumpGroup, Entity.AssetsPumpGroup>(model); |
| | | return entity; |
| | | } |
| | | |
| | | //Models to Entities |
| | | internal static List<Entity.PumpGroup> Model2Entities(List<Model.PumpGroup> models) |
| | | internal static List<Entity.AssetsPumpGroup> Model2Entities(List<Model.AssetsPumpGroup> models) |
| | | { |
| | | if (models == null || models.Count < 1) |
| | | return default; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.PumpGroup, Entity.PumpGroup>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsPumpGroup, Entity.AssetsPumpGroup>() |
| | | .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.PumpGroup>, List<Entity.PumpGroup>>(models); |
| | | var entities = mapper.Map<List<Model.AssetsPumpGroup>, List<Entity.AssetsPumpGroup>>(models); |
| | | return entities; |
| | | } |
| | | |
| | | //Model to Entity |
| | | internal static void Model2Entity(Model.PumpGroup model, Entity.PumpGroup entity) |
| | | internal static void Model2Entity(Model.AssetsPumpGroup model, Entity.AssetsPumpGroup entity) |
| | | { |
| | | if (model == null || entity == null) |
| | | return; |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.PumpGroup, Entity.PumpGroup>() |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsPumpGroup, Entity.AssetsPumpGroup>() |
| | | ).CreateMapper(); |
| | | mapper.Map(model, entity); |
| | | } |