MireaBackend/Endpoint/Common/MapperDto/AvailableProvidersConverter.cs

27 lines
1.0 KiB
C#
Raw Normal View History

2024-11-04 02:59:51 +03:00
using Mirea.Api.Dto.Responses;
using Mirea.Api.Security.Common.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Mirea.Api.Endpoint.Common.MapperDto;
public static class AvailableProvidersConverter
{
public static Dto.Common.OAuthProvider ConvertToDto(this OAuthProvider provider) =>
provider switch
{
OAuthProvider.Google => Dto.Common.OAuthProvider.Google,
OAuthProvider.Yandex => Dto.Common.OAuthProvider.Yandex,
OAuthProvider.MailRu => Dto.Common.OAuthProvider.MailRu,
_ => throw new ArgumentOutOfRangeException(nameof(provider), provider, null)
};
2024-12-18 07:29:58 +03:00
public static List<AvailableOAuthProvidersResponse> ConvertToDto(this (OAuthProvider Provider, Uri Redirect)[] data) =>
data.Select(x => new AvailableOAuthProvidersResponse()
2024-11-04 02:59:51 +03:00
{
ProviderName = Enum.GetName(x.Provider)!,
Provider = x.Provider.ConvertToDto(),
2024-12-18 07:29:58 +03:00
Redirect = x.Redirect.ToString()
2024-11-04 02:59:51 +03:00
}).ToList();
}