Files
Hushian/Presentation/HushianWebApp/Service/VerificationService.cs

50 lines
1.5 KiB
C#
Raw Normal View History

2025-07-12 16:59:25 +03:30
using Common.Dtos.Verification;
2025-07-11 20:37:28 +03:30
using Common.Enums;
using System.Net.Http.Json;
namespace HushianWebApp.Service
{
public class VerificationService
{
private readonly BaseController _baseController;
public VerificationService(BaseController baseController)
{
_baseController = baseController;
}
public async Task<int> FromUserName(string mobile, VerificationCodeType type)
{
string route = type switch
{
2025-07-12 16:59:25 +03:30
VerificationCodeType.ForgetPassword => "ForgetPassword",
2025-07-11 20:37:28 +03:30
_ => throw new NotImplementedException()
};
var response = await _baseController.Get($"v1/Verification/{route}/{mobile}");
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<int>();
}
else
{
return 0;
}
}
public async Task<bool> ConfirmedCode(ConfirmedCodeDto dto)
{
var response = await _baseController.Post($"v1/Verification/ConfirmedCode", dto);
return response.IsSuccessStatusCode;
}
public async Task<bool> ReSendCode(int ID)
{
var response = await _baseController.Get($"v1/Verification/ReSendCode/{ID}");
return response.IsSuccessStatusCode;
}
}
}