using AutoMapper; using PortBlog.API.Entities; using PortBlog.API.Models; namespace PortBlog.API.Profiles { public class BlogProfile : Profile { public BlogProfile() { CreateMap(); CreateMap() .ForMember( dest => dest.CreatedDate, opts => opts.MapFrom(src => src.CreatedDate != null ? src.CreatedDate.Value.ToString("MMM dd, yyyy") : string.Empty) ) .ForMember( dest => dest.ModifiedDate, opts => opts.MapFrom(src => !string.IsNullOrEmpty(src.ModifiedDate.ToString()) ? src.ModifiedDate.Value.ToString("MMM dd, yyyy") : string.Empty) ); CreateMap(); CreateMap(); } } }