This commit is contained in:
mmrbnjd
2025-07-03 16:38:14 +03:30
parent 87d2360b32
commit 23043dd094
4 changed files with 153 additions and 12 deletions

View File

@@ -1,5 +1,7 @@
using AutoMapper;
using Common.Dtos;
using Common.Dtos.Company;
using Common.Dtos.Exper;
using Hushian.Application.Contracts.Persistence;
using Hushian.Application.Models;
using Hushian.Application.Validation;
@@ -99,6 +101,41 @@ namespace Hushian.Application.Services
company.allowBot = @checked;
return await _CompanyRepository.UPDATEBool(company);
}
public async Task<ResponseBase<bool>> ChangePasswordCompany(ChangePasswordDto model, int CompanyID)
{
ResponseBase<bool> Response = new();
var company = await _CompanyRepository.Get().FirstOrDefaultAsync(f => f.ID == CompanyID);
if (string.IsNullOrEmpty(model.OldPassWord) || model.OldPassWord.GetHash()!=company.Password)
{
Response.Errors.Add("کلمه عبور فعلی صحیح نمی باشد");
}
else
{
company.Password = model.NewPassWord.GetHash();
Response.Value= await _CompanyRepository.UPDATEBool(company);
if (!Response.Value) Response.Errors.Add("خطا در ذخیره سازی");
else Response.Success = true;
}
return Response;
}
public async Task<ResponseBase<int>> ForgetPasswordCompany(string Mobile)
{
ResponseBase<int> Response = new();
var company = await _CompanyRepository.Get().FirstOrDefaultAsync(f => f.Mobile == Mobile);
if (company==null)
{
Response.Errors.Add("کاربری یافت نشد");
}
else
{
Response.Value= await _VerificationService.GenerateCodeByForgetPassword(Mobile);
Response.Success = true;
}
return Response;
}
private async Task<ResponseBase<bool>> NewCompany(RegisterCompanyDto dto)
{
ResponseBase<bool> Response = new();