Created
August 1, 2018 20:16
-
-
Save idotnetdev/a6946b10d13a2360d2d023f0a171cb70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ProductComments | |
{ | |
public int Id { get; set; } | |
public virtual ApplicationUser CreatedBy { get; set; } | |
public int CreatedById { get; set; } | |
public DateTime CreatedOn { get; set; } | |
public string Comment { get; set; } | |
public string Ip { get; set; } | |
public string UserAgent { get; set; } | |
public int Likes { get; set; } | |
public int Dislikes { get; set; } | |
public ProductComments Parent { get; set; } | |
public int? ParentId { get; set; } | |
public virtual Product Product { get; set; } | |
public int ProductId { get; set; } | |
public virtual ICollection<ProductComments> Childrens { get; set; } | |
} | |
public class CommentsViewModel : IHaveCustomMappings | |
{ | |
public int Id { get; set; } | |
public string CreatedBy { get; set; } | |
public DateTime CreatedOn { get; set; } | |
public string Ip { get; set; } | |
public string Comment { get; set; } | |
public int Likes { get; set; } | |
public int Dislikes { get; set; } | |
public ICollection<CommentsViewModel> Replies { get; set; } | |
public void CreateMappings(IMapperConfigurationExpression configuration) | |
{ | |
configuration.CreateMap<DomainEntities.Products.ProductComments, CommentsViewModel>() | |
.ForMember(dest => dest.CreatedBy, opt => opt.MapFrom(x => x.CreatedBy.Name + " " + x.CreatedBy.Family)) | |
.ForMember(dest => dest.Replies, opt => opt.MapFrom(x => x.Childrens)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment