mirror of
https://github.com/techgarage-ir/MTWireGuard.git
synced 2025-08-29 06:18:08 +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
|
@ -1,44 +0,0 @@
|
|||
using AutoMapper;
|
||||
using MTWireGuard.Models.Mikrotik;
|
||||
using MTWireGuard.Models.Requests;
|
||||
|
||||
namespace MTWireGuard.Mapper
|
||||
{
|
||||
public class ServerMapping : Profile
|
||||
{
|
||||
public ServerMapping()
|
||||
{
|
||||
/*
|
||||
* Convert Mikrotik Server Model to ViewModel
|
||||
*/
|
||||
CreateMap<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<CreateServerRequest, ServerCreateModel>()
|
||||
.ForMember(dest => dest.ListenPort,
|
||||
opt => opt.MapFrom(src => src.Port));
|
||||
|
||||
CreateMap<ServerCreateModel, WGServerCreateModel>()
|
||||
.ForMember(dest => dest.Disabled,
|
||||
opt => opt.MapFrom(src => !src.Enabled));
|
||||
|
||||
/*
|
||||
* Convert Wrapper UpdateModel to Rest-API UpdateModel
|
||||
*/
|
||||
CreateMap<UpdateServerRequest, ServerUpdateModel>()
|
||||
.ForMember(dest => dest.ListenPort,
|
||||
opt => opt.MapFrom(src => src.Port));
|
||||
|
||||
|
||||
CreateMap<ServerUpdateModel, WGServerUpdateModel>()
|
||||
.ForMember(dest => dest.Id,
|
||||
opt => opt.MapFrom(src => $"*{src.Id:X}"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue