Files
PortBlog.API/PortBlog.API/Profiles/BlogProfile.cs
T

26 lines
876 B
C#

using AutoMapper;
using PortBlog.API.Entities;
using PortBlog.API.Models;
namespace PortBlog.API.Profiles
{
public class BlogProfile : Profile
{
public BlogProfile()
{
CreateMap<Blog, BlogDto>();
CreateMap<Post, PostDto>()
.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<Post, PostMetricsDto>();
CreateMap<PostCreationDto, Post>();
}
}
}