refactor: improve code readability by formatting and organizing constructor parameters
This commit is contained in:
@@ -18,7 +18,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Shared.Contracts.PmUser.Commands;
|
||||
using Shared.Contracts.PmUser.Queries;
|
||||
|
||||
@@ -48,7 +47,13 @@ public class AccountApplication : IAccountApplication
|
||||
private readonly IPmUserCommandService _pmUserCommandService;
|
||||
|
||||
public AccountApplication(IAccountRepository accountRepository, IPasswordHasher passwordHasher,
|
||||
IFileUploader fileUploader, IAuthHelper authHelper, IRoleRepository roleRepository, IWorker worker, ISmsService smsService, ICameraAccountRepository cameraAccountRepository, IPositionRepository positionRepository, IAccountLeftworkRepository accountLeftworkRepository, IWorkshopRepository workshopRepository, ISubAccountRepository subAccountRepository, ISubAccountRoleRepository subAccountRoleRepository, IWorkshopSubAccountRepository workshopSubAccountRepository, ISubAccountPermissionSubtitle1Repository accountPermissionSubtitle1Repository, IUnitOfWork unitOfWork, IPmUserQueryService pmUserQueryService, IPmUserCommandService pmUserCommandService)
|
||||
IFileUploader fileUploader, IAuthHelper authHelper, IRoleRepository roleRepository, IWorker worker,
|
||||
ISmsService smsService, ICameraAccountRepository cameraAccountRepository,
|
||||
IPositionRepository positionRepository, IAccountLeftworkRepository accountLeftworkRepository,
|
||||
IWorkshopRepository workshopRepository, ISubAccountRepository subAccountRepository,
|
||||
ISubAccountRoleRepository subAccountRoleRepository, IWorkshopSubAccountRepository workshopSubAccountRepository,
|
||||
ISubAccountPermissionSubtitle1Repository accountPermissionSubtitle1Repository, IUnitOfWork unitOfWork,
|
||||
IPmUserQueryService pmUserQueryService, IPmUserCommandService pmUserCommandService)
|
||||
{
|
||||
_authHelper = authHelper;
|
||||
_roleRepository = roleRepository;
|
||||
@@ -68,7 +73,6 @@ public class AccountApplication : IAccountApplication
|
||||
_fileUploader = fileUploader;
|
||||
_passwordHasher = passwordHasher;
|
||||
_accountRepository = accountRepository;
|
||||
|
||||
}
|
||||
|
||||
public OperationResult EditClient(EditClientAccount command)
|
||||
@@ -89,7 +93,8 @@ public class AccountApplication : IAccountApplication
|
||||
(x.Mobile == command.Mobile && x.id != command.Id)))
|
||||
return opreation.Failed("شماره موبایل تکراری است");
|
||||
if (_accountRepository.Exists(x =>
|
||||
(x.NationalCode == command.NationalCode && !string.IsNullOrWhiteSpace(x.NationalCode) && x.id != command.Id)))
|
||||
(x.NationalCode == command.NationalCode && !string.IsNullOrWhiteSpace(x.NationalCode) &&
|
||||
x.id != command.Id)))
|
||||
return opreation.Failed("کد ملی تکراری است");
|
||||
if (_accountRepository.Exists(x =>
|
||||
(x.Email == command.Email && !string.IsNullOrWhiteSpace(x.Email) && x.id != command.Id)))
|
||||
@@ -97,7 +102,8 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
var path = $"profilePhotos";
|
||||
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||
editAccount.EditClient(command.Fullname, command.Username, command.Mobile, picturePath, command.Email, command.NationalCode);
|
||||
editAccount.EditClient(command.Fullname, command.Username, command.Mobile, picturePath, command.Email,
|
||||
command.NationalCode);
|
||||
_accountRepository.SaveChanges();
|
||||
return opreation.Succcedded();
|
||||
}
|
||||
@@ -142,8 +148,8 @@ public class AccountApplication : IAccountApplication
|
||||
if (_fileUploader != null)
|
||||
{
|
||||
picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||
|
||||
}
|
||||
|
||||
var account = new Account(command.Fullname, command.Username, password, command.Mobile, command.RoleId,
|
||||
picturePath, roleName.Name, "true", "false");
|
||||
|
||||
@@ -158,7 +164,8 @@ public class AccountApplication : IAccountApplication
|
||||
if (command.UserRoles == null)
|
||||
return operation.Failed("حداقل یک نقش برای کاربر مدیریت پروژه لازم است");
|
||||
var pmUserRoles = command.UserRoles.Where(x => x > 0).ToList();
|
||||
var createPm = await _pmUserCommandService.Create(new CreatePmUserDto(command.Fullname, command.Username, account.Password, command.Mobile,
|
||||
var createPm = await _pmUserCommandService.Create(new CreatePmUserDto(command.Fullname, command.Username,
|
||||
account.Password, command.Mobile,
|
||||
null, account.id, pmUserRoles));
|
||||
if (!createPm.isSuccess)
|
||||
{
|
||||
@@ -167,7 +174,6 @@ public class AccountApplication : IAccountApplication
|
||||
}
|
||||
|
||||
|
||||
|
||||
//var url = "api/user/create";
|
||||
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
@@ -252,14 +258,14 @@ public class AccountApplication : IAccountApplication
|
||||
// $"api/user/{account.id}",
|
||||
// key
|
||||
//);
|
||||
var userResult =await _pmUserQueryService.GetPmUserDataByAccountId(account.id);
|
||||
var userResult = await _pmUserQueryService.GetPmUserDataByAccountId(account.id);
|
||||
|
||||
if (command.UserRoles == null)
|
||||
return operation.Failed("حداقل یک نقش برای کاربر مدیریت پروژه لازم است");
|
||||
var pmUserRoles = command.UserRoles.Where(x => x > 0).ToList();
|
||||
|
||||
//اگر کاربر در پروگرام منیجر قبلا ایجاد شده
|
||||
if (userResult.Id >0)
|
||||
if (userResult.Id > 0)
|
||||
{
|
||||
if (!command.UserRoles.Any())
|
||||
{
|
||||
@@ -267,7 +273,8 @@ public class AccountApplication : IAccountApplication
|
||||
return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||
}
|
||||
|
||||
var editPm =await _pmUserCommandService.Edit(new EditPmUserDto(command.Fullname, command.Username, command.Mobile, account.id, pmUserRoles,
|
||||
var editPm = await _pmUserCommandService.Edit(new EditPmUserDto(command.Fullname, command.Username,
|
||||
command.Mobile, account.id, pmUserRoles,
|
||||
command.IsProgramManagerUser));
|
||||
if (!editPm.isSuccess)
|
||||
{
|
||||
@@ -302,7 +309,6 @@ public class AccountApplication : IAccountApplication
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Error);
|
||||
//}
|
||||
|
||||
}
|
||||
else //اگر کاربر قبلا ایجاد نشده
|
||||
{
|
||||
@@ -316,11 +322,8 @@ public class AccountApplication : IAccountApplication
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var createPm = await _pmUserCommandService.Create(new CreatePmUserDto(command.Fullname, command.Username, account.Password, command.Mobile,
|
||||
var createPm = await _pmUserCommandService.Create(new CreatePmUserDto(command.Fullname,
|
||||
command.Username, account.Password, command.Mobile,
|
||||
null, account.id, pmUserRoles));
|
||||
if (!createPm.isSuccess)
|
||||
{
|
||||
@@ -329,7 +332,6 @@ public class AccountApplication : IAccountApplication
|
||||
}
|
||||
|
||||
|
||||
|
||||
//var parameters = new CreateProgramManagerUser(
|
||||
// command.Fullname,
|
||||
// command.Username,
|
||||
@@ -362,7 +364,6 @@ public class AccountApplication : IAccountApplication
|
||||
// return operation.Failed(response.Error);
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_unitOfWork.CommitAccountContext();
|
||||
@@ -376,7 +377,6 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
public OperationResult Login(Login command)
|
||||
{
|
||||
|
||||
long idAutoriz = 0;
|
||||
var operation = new OperationResult();
|
||||
if (string.IsNullOrWhiteSpace(command.Password))
|
||||
@@ -401,19 +401,25 @@ public class AccountApplication : IAccountApplication
|
||||
.Select(x => x.Code)
|
||||
.ToList();
|
||||
//PmPermission
|
||||
var PmUserData = _pmUserQueryService.GetPmUserDataByAccountId(account.id).GetAwaiter().GetResult();
|
||||
if (PmUserData.AccountId > 0 && PmUserData.IsActive)
|
||||
var PmUserData = _pmUserQueryService.GetPmUserDataByAccountId(account.id)
|
||||
.GetAwaiter().GetResult();
|
||||
long? pmUserId = null;
|
||||
if (PmUserData != null)
|
||||
{
|
||||
if (PmUserData.AccountId > 0 && PmUserData.IsActive)
|
||||
{
|
||||
var pmUserPermissions =
|
||||
PmUserData.RoleListDto != null
|
||||
? PmUserData.RoleListDto
|
||||
.SelectMany(x => x.Permissions)
|
||||
.Where(p => p != 99)
|
||||
.Distinct()
|
||||
.ToList()
|
||||
: new List<int>();
|
||||
permissions.AddRange(pmUserPermissions);
|
||||
}
|
||||
|
||||
var pmUserPermissions =
|
||||
PmUserData.RoleListDto != null
|
||||
? PmUserData.RoleListDto
|
||||
.SelectMany(x => x.Permissions)
|
||||
.Where(p => p != 99)
|
||||
.Distinct()
|
||||
.ToList()
|
||||
: new List<int>();
|
||||
permissions.AddRange(pmUserPermissions);
|
||||
pmUserId = PmUserData.Id > 0 ? PmUserData.Id : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -426,24 +432,25 @@ public class AccountApplication : IAccountApplication
|
||||
{
|
||||
positionValue = null;
|
||||
}
|
||||
var pmUserId = PmUserData.AccountId > 0 ? PmUserData.AccountId : null;
|
||||
|
||||
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
|
||||
, account.Username, account.Mobile, account.ProfilePhoto,
|
||||
permissions, account.RoleName, account.AdminAreaPermission,
|
||||
account.ClientAriaPermission, positionValue,0,pmUserId);
|
||||
account.ClientAriaPermission, positionValue, 0, pmUserId);
|
||||
|
||||
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" &&
|
||||
account.IsActiveString == "true")
|
||||
{
|
||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||
authViewModel.Permissions = clientPermissions;
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.Id,
|
||||
Name = x.WorkshopFullName,
|
||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x =>
|
||||
new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.Id,
|
||||
Name = x.WorkshopFullName,
|
||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||
authViewModel.WorkshopList = workshopList;
|
||||
if (workshopList.Any())
|
||||
{
|
||||
@@ -456,10 +463,14 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
_authHelper.Signin(authViewModel);
|
||||
|
||||
if ((account.AdminAreaPermission == "true" && account.ClientAriaPermission == "true" && account.IsActiveString == "true") || (account.AdminAreaPermission == "true" && account.ClientAriaPermission == "false" && account.IsActiveString == "true"))
|
||||
if ((account.AdminAreaPermission == "true" && account.ClientAriaPermission == "true" &&
|
||||
account.IsActiveString == "true") || (account.AdminAreaPermission == "true" &&
|
||||
account.ClientAriaPermission == "false" &&
|
||||
account.IsActiveString == "true"))
|
||||
idAutoriz = 1;
|
||||
|
||||
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" && account.IsActiveString == "true")
|
||||
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" &&
|
||||
account.IsActiveString == "true")
|
||||
idAutoriz = 2;
|
||||
}
|
||||
|
||||
@@ -471,7 +482,8 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId, cameraAccount.IsActiveSting);
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId,
|
||||
cameraAccount.IsActiveSting);
|
||||
if (cameraAccount.IsActiveSting == "true")
|
||||
{
|
||||
_authHelper.CameraSignIn(authViewModel);
|
||||
@@ -481,7 +493,6 @@ public class AccountApplication : IAccountApplication
|
||||
{
|
||||
idAutoriz = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (subAccount != null)
|
||||
@@ -511,12 +522,14 @@ public class AccountApplication : IAccountApplication
|
||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.WorkshopId);
|
||||
authViewModel.WorkshopId = workshop.WorkshopId;
|
||||
}
|
||||
|
||||
_authHelper.Signin(authViewModel);
|
||||
idAutoriz = 2;
|
||||
}
|
||||
|
||||
return operation.Succcedded(idAutoriz);
|
||||
}
|
||||
|
||||
public OperationResult LoginWithMobile(long id)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
@@ -525,7 +538,6 @@ public class AccountApplication : IAccountApplication
|
||||
return operation.Failed(ApplicationMessages.WrongUserPass);
|
||||
|
||||
|
||||
|
||||
var permissions = _roleRepository.Get(account.RoleId)
|
||||
.Permissions
|
||||
.Select(x => x.Code)
|
||||
@@ -541,20 +553,22 @@ public class AccountApplication : IAccountApplication
|
||||
}
|
||||
|
||||
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
|
||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, account.AdminAreaPermission, account.ClientAriaPermission, positionValue);
|
||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName,
|
||||
account.AdminAreaPermission, account.ClientAriaPermission, positionValue);
|
||||
|
||||
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" &&
|
||||
account.IsActiveString == "true")
|
||||
{
|
||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||
authViewModel.Permissions = clientPermissions;
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.Id,
|
||||
Name = x.WorkshopFullName,
|
||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x =>
|
||||
new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.Id,
|
||||
Name = x.WorkshopFullName,
|
||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||
authViewModel.WorkshopList = workshopList;
|
||||
if (workshopList.Any())
|
||||
{
|
||||
@@ -567,13 +581,15 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
_authHelper.Signin(authViewModel);
|
||||
long idAutoriz = 0;
|
||||
if (account.AdminAreaPermission == "true" && account.ClientAriaPermission == "true" || account.AdminAreaPermission == "true" && account.ClientAriaPermission == "false")
|
||||
if (account.AdminAreaPermission == "true" && account.ClientAriaPermission == "true" ||
|
||||
account.AdminAreaPermission == "true" && account.ClientAriaPermission == "false")
|
||||
idAutoriz = 1;
|
||||
|
||||
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false")
|
||||
idAutoriz = 2;
|
||||
return operation.Succcedded(idAutoriz);
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
_authHelper.SignOut();
|
||||
@@ -609,6 +625,7 @@ public class AccountApplication : IAccountApplication
|
||||
_accountRepository.SaveChanges();
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
public EditAccount GetByVerifyCode(string code, string phone)
|
||||
{
|
||||
return _accountRepository.GetByVerifyCode(code, phone);
|
||||
@@ -637,7 +654,6 @@ public class AccountApplication : IAccountApplication
|
||||
await _accountRepository.RemoveCode(id);
|
||||
|
||||
return operation.Succcedded();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -682,7 +698,6 @@ public class AccountApplication : IAccountApplication
|
||||
return operation.Failed("این اکانت وجود ندارد");
|
||||
|
||||
|
||||
|
||||
var permissions = _roleRepository.Get(account.RoleId)
|
||||
.Permissions
|
||||
.Select(x => x.Code)
|
||||
@@ -691,7 +706,8 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
_authHelper.SignOut();
|
||||
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
|
||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, "false", "true", null);
|
||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, "false", "true",
|
||||
null);
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
@@ -711,9 +727,11 @@ public class AccountApplication : IAccountApplication
|
||||
authViewModel.WorkshopName = workshop.Name;
|
||||
authViewModel.WorkshopId = workshop.Id;
|
||||
}
|
||||
|
||||
_authHelper.Signin(authViewModel);
|
||||
return operation.Succcedded(2);
|
||||
}
|
||||
|
||||
public OperationResult DirectCameraLogin(long cameraAccountId)
|
||||
{
|
||||
var prAcc = _authHelper.CurrentAccountInfo();
|
||||
@@ -723,24 +741,22 @@ public class AccountApplication : IAccountApplication
|
||||
return operation.Failed("این اکانت وجود ندارد");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
_authHelper.SignOut();
|
||||
|
||||
|
||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId, cameraAccount.IsActiveSting);
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId,
|
||||
cameraAccount.IsActiveSting);
|
||||
if (cameraAccount.IsActiveSting == "true")
|
||||
{
|
||||
_authHelper.CameraSignIn(authViewModel);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return operation.Failed("این اکانت غیر فعال شده است");
|
||||
}
|
||||
|
||||
return operation.Succcedded(2);
|
||||
}
|
||||
|
||||
@@ -773,10 +789,12 @@ public class AccountApplication : IAccountApplication
|
||||
{
|
||||
return this._accountLeftworkRepository.SaveWorkshopAccount(workshopAccountList, startDate, leftDate, accountId);
|
||||
}
|
||||
|
||||
public OperationResult CreateNewWorkshopAccount(long currentAccountId, long newAccountId)
|
||||
{
|
||||
return this._accountLeftworkRepository.CopyWorkshopToNewAccount(currentAccountId, newAccountId);
|
||||
}
|
||||
|
||||
#region Mahan
|
||||
|
||||
public List<AccountViewModel> AccountsForAssign(long taskId)
|
||||
@@ -790,6 +808,7 @@ public class AccountApplication : IAccountApplication
|
||||
{
|
||||
return new List<AccountViewModel>();
|
||||
}
|
||||
|
||||
return _accountRepository.GetAccountsByPositionId(positionId);
|
||||
}
|
||||
|
||||
@@ -807,7 +826,6 @@ public class AccountApplication : IAccountApplication
|
||||
return operation.Failed("این اکانت وجود ندارد");
|
||||
|
||||
|
||||
|
||||
var permissions = _roleRepository.Get(account.RoleId)
|
||||
.Permissions
|
||||
.Select(x => x.Code)
|
||||
@@ -816,10 +834,10 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
_authHelper.SignOut();
|
||||
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
|
||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, account.AdminAreaPermission, account.ClientAriaPermission, account.Position.PositionValue);
|
||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName,
|
||||
account.AdminAreaPermission, account.ClientAriaPermission, account.Position.PositionValue);
|
||||
_authHelper.Signin(authViewModel);
|
||||
return operation.Succcedded(2);
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<AccountSelectListViewModel>> GetAdminSelectList()
|
||||
@@ -828,8 +846,11 @@ public class AccountApplication : IAccountApplication
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Pooya
|
||||
public OperationResult IsPhoneNumberAndPasswordValid(long accountId, string phoneNumber, string password, string rePassword)
|
||||
|
||||
public OperationResult IsPhoneNumberAndPasswordValid(long accountId, string phoneNumber, string password,
|
||||
string rePassword)
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
@@ -847,7 +868,8 @@ public class AccountApplication : IAccountApplication
|
||||
return op.Failed("رمز عبور نمی تواند کمتر از 8 کاراکتر باشد");
|
||||
}
|
||||
|
||||
if ((string.IsNullOrWhiteSpace(phoneNumber) || entity.Mobile == phoneNumber) && string.IsNullOrWhiteSpace(rePassword))
|
||||
if ((string.IsNullOrWhiteSpace(phoneNumber) || entity.Mobile == phoneNumber) &&
|
||||
string.IsNullOrWhiteSpace(rePassword))
|
||||
return op.Failed("چیزی برای تغییر وجود ندارد");
|
||||
|
||||
|
||||
@@ -873,20 +895,22 @@ public class AccountApplication : IAccountApplication
|
||||
var entity = _accountRepository.Get(command.AccountId);
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
var validationResult = IsPhoneNumberAndPasswordValid(command.AccountId, command.PhoneNumber, command.Password, command.RePassword);
|
||||
var validationResult = IsPhoneNumberAndPasswordValid(command.AccountId, command.PhoneNumber, command.Password,
|
||||
command.RePassword);
|
||||
if (validationResult.IsSuccedded == false)
|
||||
return validationResult;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.RePassword))
|
||||
{
|
||||
|
||||
entity.ChangePassword(_passwordHasher.Hash(command.Password));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.PhoneNumber))
|
||||
{
|
||||
entity.Edit(entity.Fullname, entity.Username, command.PhoneNumber, entity.RoleId, entity.ProfilePhoto, entity.RoleName);
|
||||
entity.Edit(entity.Fullname, entity.Username, command.PhoneNumber, entity.RoleId, entity.ProfilePhoto,
|
||||
entity.RoleName);
|
||||
}
|
||||
|
||||
_accountRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
@@ -982,6 +1006,7 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
// return claimsResponse.Failed(ApplicationMessages.WrongUserPass);
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1024,5 +1049,4 @@ public class AccountApplication : IAccountApplication
|
||||
{
|
||||
return await _pmUserQueryService.GetPmUserDataByAccountId(accountId);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user