Ejemplo n.º 1
0
        public AutoMapperProfiles()
        {
            CreateMap <AppUser, MemberDTO>()
            .ForMember(
                dest => dest.PhotoUrl,
                opt => opt.MapFrom(
                    src => src.Photos.FirstOrDefault(
                        x => x.IsMain
                        ).Url))
            .ForMember(
                dest => dest.Age,
                OPT => OPT.MapFrom(
                    src => src.DateOfBirth.CalculateAge()
                    ));

            CreateMap <Photo, PhotoDTO>();

            CreateMap <MemberUpdateDTO, AppUser>();
        }
Ejemplo n.º 2
0
        public MappingUserProfile()
        {
            CreateMap <M.Request.UsuarioRequest, M.Entidades.USER_LAB>()
            .ForMember(DEST => DEST.EMAIL, OPT => OPT.MapFrom(input => input.correo))
            .ForMember(DEST => DEST.FIRST_LAST_NAME, OPT => OPT.MapFrom(input => input.apellidoPaterno))
            .ForMember(DEST => DEST.SECOND_LAST_NAME, OPT => OPT.MapFrom(input => input.apellidoMaterno))
            .ForMember(DEST => DEST.FIRST_NAME, OPT => OPT.MapFrom(input => input.primerNombre))
            .ForMember(DEST => DEST.SECOND_NAME, OPT => OPT.MapFrom(input => input.segundoNombre))
            .ForMember(DEST => DEST.PASSWORD, OPT => OPT.MapFrom(input => input.contrasena))
            .ForMember(DEST => DEST.USR, OPT => OPT.MapFrom(input => input.usuario))
            .ForMember(DEST => DEST.ID_USER_ROL, OPT => OPT.MapFrom(input => input.idRol)).ReverseMap();

            CreateMap <M.Response.UsuarioResponse, M.Entidades.USER_LAB>()
            .ForMember(DEST => DEST.EMAIL, OPT => OPT.MapFrom(input => input.correo))
            .ForMember(DEST => DEST.FIRST_LAST_NAME, OPT => OPT.MapFrom(input => input.apellidoPaterno))
            .ForMember(DEST => DEST.SECOND_LAST_NAME, OPT => OPT.MapFrom(input => input.apellidoMaterno))
            .ForMember(DEST => DEST.FIRST_NAME, OPT => OPT.MapFrom(input => input.primerNombre))
            .ForMember(DEST => DEST.SECOND_NAME, OPT => OPT.MapFrom(input => input.segundoNombre))
            .ForMember(DEST => DEST.PASSWORD, OPT => OPT.MapFrom(input => input.contrasena))
            .ForMember(DEST => DEST.USR, OPT => OPT.MapFrom(input => input.usuario))
            .ForMember(DEST => DEST.ID_USER_ROL, OPT => OPT.MapFrom(input => input.idRol)).ReverseMap();
        }