-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMappingConfig.cs
39 lines (29 loc) · 952 Bytes
/
MappingConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using AutoMapper;
using InvestSense_API.DTOs;
using InvestSense_API.Models;
using Microsoft.EntityFrameworkCore.Metadata;
using System.Text.RegularExpressions;
namespace InvestSense_API
{
public class MappingConfig
{
public static MapperConfiguration RegisterMaps()
{
var mappingConfig = new MapperConfiguration(config =>
{
config.CreateMap<Stock, StockDTO>();
config.CreateMap<StockDTO, Stock>();
config.CreateMap<Stock, CreateStockRequestDTO>();
config.CreateMap<CreateStockRequestDTO, Stock>();
config.CreateMap<FMPStock, Stock>();
config.CreateMap<Comment, CommentDTO>()
.ForMember(dest => dest.CreatedBy, opt => opt.MapFrom(src => src.AppUser != null ? src.AppUser.UserName : null));
config.CreateMap<CommentDTO, Comment>();
config.CreateMap<Comment, CreateCommentRequestDTO>();
config.CreateMap<CreateCommentRequestDTO, Comment>();
});
return mappingConfig;
}
}
}