mirror of
https://github.com/techgarage-ir/MTWireGuard.git
synced 2025-08-28 22:08: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
58
UI/Mapper/RequestProfile.cs
Normal file
58
UI/Mapper/RequestProfile.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using AutoMapper;
|
||||
using MTWireGuard.Application.Models;
|
||||
using MTWireGuard.Application.Models.Mikrotik;
|
||||
using MTWireGuard.Models.Requests;
|
||||
using MTWireGuard.Models.Responses;
|
||||
|
||||
namespace MTWireGuard.Mapper
|
||||
{
|
||||
public class RequestProfile : Profile
|
||||
{
|
||||
public RequestProfile()
|
||||
{
|
||||
// Peer Request
|
||||
CreateMap<CreateClientRequest, UserCreateModel>()
|
||||
.ForMember(dest => dest.Disabled,
|
||||
opt => opt.MapFrom(src => !src.Enabled))
|
||||
.ForMember(dest => dest.EndpointAddress,
|
||||
opt => opt.MapFrom(src => src.Endpoint))
|
||||
.ForMember(dest => dest.PersistentKeepalive,
|
||||
opt => opt.MapFrom(src => src.KeepAlive.ToString()));
|
||||
|
||||
CreateMap<SyncUserRequest, UserSyncModel>();
|
||||
|
||||
CreateMap<UpdateClientRequest, UserUpdateModel>()
|
||||
.ForMember(dest => dest.EndpointAddress,
|
||||
opt => opt.MapFrom(src => src.Endpoint))
|
||||
.ForMember(dest => dest.PersistentKeepalive,
|
||||
opt => opt.MapFrom(src => src.KeepAlive));
|
||||
|
||||
// Server Request
|
||||
CreateMap<CreateServerRequest, ServerCreateModel>()
|
||||
.ForMember(dest => dest.ListenPort,
|
||||
opt => opt.MapFrom(src => src.Port));
|
||||
|
||||
CreateMap<UpdateServerRequest, ServerUpdateModel>()
|
||||
.ForMember(dest => dest.ListenPort,
|
||||
opt => opt.MapFrom(src => src.Port));
|
||||
|
||||
// Item Creation
|
||||
CreateMap<MikrotikAPI.Models.CreationStatus, CreationResult>()
|
||||
.ForMember(dest => dest.Code,
|
||||
opt => opt.MapFrom(src => (src.Success) ? "200" : src.Code.ToString()))
|
||||
.ForMember(dest => dest.Title,
|
||||
opt => opt.MapFrom(src => (src.Success) ? "Done" : src.Message))
|
||||
.ForMember(dest => dest.Description,
|
||||
opt => opt.MapFrom(src => (src.Success) ? "Item created/updated successfully." : src.Detail));
|
||||
|
||||
// Toast Result
|
||||
CreateMap<CreationResult, ToastMessage>()
|
||||
.ForMember(dest => dest.Title,
|
||||
opt => opt.MapFrom(src => src.Code == "200" ? src.Title : $"[{src.Code}] {src.Title}"))
|
||||
.ForMember(dest => dest.Body,
|
||||
opt => opt.MapFrom(src => src.Description))
|
||||
.ForMember(dest => dest.Background,
|
||||
opt => opt.MapFrom(src => src.Code == "200" ? "success" : "danger"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue