Exemplo n.º 1
0
        /// <summary>
        /// Maps two models using AutoMapper.
        /// Both types must be mapped.
        /// </summary>
        public static T Map <T>(this IIdentifiable source, int id)
            where T : class, IIdentifiable, new()
        {
            if (source == null)
            {
                return(null);
            }

            var result = source.Map <T>();

            if (result == null)
            {
                return(null);
            }

            result.Id = id;

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Maps two models using AutoMapper.
        /// Both types must be mapped.
        /// </summary>
        public static DestinationType Map <DestinationType>(this IIdentifiable source, int id)
            where DestinationType : class, IIdentifiable, new()
        {
            if (source == null)
            {
                return(null);
            }

            // Realiza o mapeamento
            var result = source.Map <DestinationType>();

            if (result == null)
            {
                return(null);
            }

            // Associa o ID, se for informado
            result.Id = id;

            return(result);
        }