mirror of
https://github.com/techgarage-ir/MTWireGuard.git
synced 2025-08-29 14:28:09 +02:00
Change project to 3-Layer structure
This commit is contained in:
parent
2f900a5036
commit
2d67540e13
1365 changed files with 760 additions and 618 deletions
34
Application/Mapper/ServerMapping.cs
Normal file
34
Application/Mapper/ServerMapping.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using AutoMapper;
|
||||
using MTWireGuard.Application.Models.Mikrotik;
|
||||
|
||||
namespace MTWireGuard.Application.Mapper
|
||||
{
|
||||
public class ServerMapping : Profile
|
||||
{
|
||||
public ServerMapping()
|
||||
{
|
||||
/*
|
||||
* Convert Mikrotik Server Model to ViewModel
|
||||
*/
|
||||
CreateMap<MikrotikAPI.Models.WGServer, WGServerViewModel>()
|
||||
.ForMember(dest => dest.Id,
|
||||
opt => opt.MapFrom(src => Convert.ToInt32(src.Id.Substring(1), 16)))
|
||||
.ForMember(dest => dest.IsEnabled,
|
||||
opt => opt.MapFrom(src => !src.Disabled));
|
||||
|
||||
/*
|
||||
* Convert Wrapper CreateModel to Rest-API CreateModel
|
||||
*/
|
||||
CreateMap<ServerCreateModel, MikrotikAPI.Models.WGServerCreateModel>()
|
||||
.ForMember(dest => dest.Disabled,
|
||||
opt => opt.MapFrom(src => !src.Enabled));
|
||||
|
||||
/*
|
||||
* Convert Wrapper UpdateModel to Rest-API UpdateModel
|
||||
*/
|
||||
CreateMap<ServerUpdateModel, MikrotikAPI.Models.WGServerUpdateModel>()
|
||||
.ForMember(dest => dest.Id,
|
||||
opt => opt.MapFrom(src => $"*{src.Id:X}"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue