This commit is contained in:
mmrbnjd
2025-07-11 20:37:28 +03:30
parent 1924c88e7a
commit ff342a53c0
156 changed files with 13746 additions and 35 deletions

View File

@@ -0,0 +1,52 @@
using Common.Dtos.User;
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
{
VerificationCodeType.PhoneNumberConfirmed => "PhoneNumberConfirmedFromUserName",
VerificationCodeType.ForgetPassword => "ForgetPasswordFromUserName",
VerificationCodeType.ChangeMobile => throw new NotImplementedException(),
VerificationCodeType.Login => throw new NotImplementedException(),
_ => 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;
}
}
}