duheng
2024-11-26 6fcff08e4f76bce6076319b5b3a2456c2d94c5fe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using AutoMapper;
 
namespace Yw.BLL
{
    /// <summary>
    ///
    ///</summary>
    public partial class BuildingType
    {
        //dto to vmo
        internal static Vmo.BuildingTypeVmo Dto2Vmo(Dto.BuildingTypeDto dto)
        {
            if (dto == null)
            {
                return default;
            }
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Dto.BuildingTypeDto, Vmo.BuildingTypeVmo>()
            ).CreateMapper();
            var vmo = mapper.Map<Dto.BuildingTypeDto, Vmo.BuildingTypeVmo>(dto);
            return vmo;
        }
 
        //dto to vmos
        internal static List<Vmo.BuildingTypeVmo> Dto2Vmos(List<Dto.BuildingTypeDto> dtos)
        {
            if (dtos == null || dtos.Count < 1)
            {
                return default;
            }
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Dto.BuildingTypeDto, Vmo.BuildingTypeVmo>()
            ).CreateMapper();
            var vmos = mapper.Map<List<Dto.BuildingTypeDto>, List<Vmo.BuildingTypeVmo>>(dtos);
            return vmos;
        }
 
        //vmo to add dto
        internal static Dto.AddBuildingTypeInput Vmo2AddDto(Vmo.BuildingTypeVmo vmo)
        {
            if (vmo == null)
            {
                return default;
            }
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Vmo.BuildingTypeVmo, Dto.AddBuildingTypeInput>()
            ).CreateMapper();
            var dto = mapper.Map<Vmo.BuildingTypeVmo, Dto.AddBuildingTypeInput>(vmo);
            return dto;
        }
 
        //vmo to add dtos
        internal static List<Dto.AddBuildingTypeInput> Vmo2AddDtos(List<Vmo.BuildingTypeVmo> vmoList)
        {
            if (vmoList == null || vmoList.Count < 1)
            {
                return default;
            }
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Vmo.BuildingTypeVmo, Dto.AddBuildingTypeInput>()
            ).CreateMapper();
            var dtoList = mapper.Map<List<Vmo.BuildingTypeVmo>, List<Dto.AddBuildingTypeInput>>(vmoList);
            return dtoList;
        }
 
        //vmo to update dto
        internal static Dto.UpdateBuildingTypeInput Vmo2UpdateDto(Vmo.BuildingTypeVmo vmo)
        {
            if (vmo == null)
            {
                return default;
            }
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Vmo.BuildingTypeVmo, Dto.UpdateBuildingTypeInput>()
            ).CreateMapper();
            var dto = mapper.Map<Vmo.BuildingTypeVmo, Dto.UpdateBuildingTypeInput>(vmo);
            return dto;
        }
 
        //vmo to update dtos
        internal static List<Dto.UpdateBuildingTypeInput> Vmo2UpdateDtos(List<Vmo.BuildingTypeVmo> vmoList)
        {
            if (vmoList == null || vmoList.Count < 1)
            {
                return default;
            }
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Vmo.BuildingTypeVmo, Dto.UpdateBuildingTypeInput>()
            ).CreateMapper();
            var dtoList = mapper.Map<List<Vmo.BuildingTypeVmo>, List<Dto.UpdateBuildingTypeInput>>(vmoList);
            return dtoList;
        }
    }
}