change accountTable
This commit is contained in:
@@ -155,7 +155,7 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
}
|
||||
var account = new Account(command.Fullname, command.Username, password, command.Mobile, command.RoleId,
|
||||
picturePath, roleName.Name, "true", "false");
|
||||
picturePath, roleName.Name, "true", "false", command.IsProgramManagerUser);
|
||||
|
||||
_unitOfWork.BeginAccountContext();
|
||||
|
||||
@@ -163,64 +163,64 @@ public class AccountApplication : IAccountApplication
|
||||
_accountRepository.Create(account);
|
||||
_accountRepository.SaveChanges();
|
||||
|
||||
if (command.IsProgramManagerUser)
|
||||
{
|
||||
//if (command.IsProgramManagerUser)
|
||||
//{
|
||||
|
||||
try
|
||||
{
|
||||
if (_pmUserRepository.Exists(x => x.FullName == command.Fullname))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("نام و خانوادگی تکراری است");
|
||||
}
|
||||
// try
|
||||
// {
|
||||
// if (_pmUserRepository.Exists(x => x.FullName == command.Fullname))
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("نام و خانوادگی تکراری است");
|
||||
// }
|
||||
|
||||
if (_pmUserRepository.Exists(x => x.UserName == command.Username))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("نام کاربری تکراری است");
|
||||
}
|
||||
// if (_pmUserRepository.Exists(x => x.UserName == command.Username))
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("نام کاربری تکراری است");
|
||||
// }
|
||||
|
||||
if (_pmUserRepository.Exists(x => !string.IsNullOrWhiteSpace(x.Mobile) && x.Mobile == command.Mobile))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("این شماره همراه قبلا به فرد دیگری اختصاص داده شده است");
|
||||
}
|
||||
// if (_pmUserRepository.Exists(x => !string.IsNullOrWhiteSpace(x.Mobile) && x.Mobile == command.Mobile))
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("این شماره همراه قبلا به فرد دیگری اختصاص داده شده است");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
|
||||
var create = new PmUser(command.Fullname, command.Username, command.Password, command.Mobile,
|
||||
null, account.id, userRoles);
|
||||
await _pmUserRepository.CreateAsync(create);
|
||||
await _pmUserRepository.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("خطا در ایجاد کاربر پروگرام منیجر");
|
||||
}
|
||||
// var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
|
||||
// var create = new PmUser(command.Fullname, command.Username, command.Password, command.Mobile,
|
||||
// null, account.id, userRoles);
|
||||
// await _pmUserRepository.CreateAsync(create);
|
||||
// await _pmUserRepository.SaveChangesAsync();
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("خطا در ایجاد کاربر پروگرام منیجر");
|
||||
// }
|
||||
|
||||
//var url = "api/user/create";
|
||||
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||
// //var url = "api/user/create";
|
||||
// //var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
//var response = InternalApiCaller.PostAsync<CreateProgramManagerUser, ApiResponse>(
|
||||
// url,
|
||||
// key,
|
||||
// parameters
|
||||
//);
|
||||
// //var response = InternalApiCaller.PostAsync<CreateProgramManagerUser, ApiResponse>(
|
||||
// // url,
|
||||
// // key,
|
||||
// // parameters
|
||||
// //);
|
||||
|
||||
//if (!response.Success)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Error);
|
||||
//}
|
||||
// //if (!response.Success)
|
||||
// //{
|
||||
// // _unitOfWork.RollbackAccountContext();
|
||||
// // return operation.Failed(response.Error);
|
||||
// //}
|
||||
|
||||
//if (!response.Result.isSuccess)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Result.errorMessage);
|
||||
//}
|
||||
}
|
||||
// //if (!response.Result.isSuccess)
|
||||
// //{
|
||||
// // _unitOfWork.RollbackAccountContext();
|
||||
// // return operation.Failed(response.Result.errorMessage);
|
||||
// //}
|
||||
//}
|
||||
|
||||
_unitOfWork.CommitAccountContext();
|
||||
return operation.Succcedded();
|
||||
@@ -276,148 +276,148 @@ public class AccountApplication : IAccountApplication
|
||||
var path = $"profilePhotos";
|
||||
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||
_unitOfWork.BeginAccountContext();
|
||||
account.Edit(command.Fullname, command.Username, command.Mobile, command.RoleId, picturePath, roleName.Name);
|
||||
account.Edit(command.Fullname, command.Username, command.Mobile, command.RoleId, picturePath, roleName.Name, command.IsProgramManagerUser);
|
||||
_accountRepository.SaveChanges();
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
// var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
//var apiResult = InternalApiCaller.GetAsync<SingleUserResponseResult>(
|
||||
// $"api/user/{account.id}",
|
||||
// key
|
||||
//);
|
||||
var userResult = _pmUserRepository.GetByPmUsertoEditbyAccountId(account.id).GetAwaiter().GetResult();
|
||||
// var userResult = _pmUserRepository.GetByPmUsertoEditbyAccountId(account.id).GetAwaiter().GetResult();
|
||||
|
||||
|
||||
|
||||
//اگر کاربر در پروگرام منیجر قبلا ایجاد شده
|
||||
if (userResult != null)
|
||||
{
|
||||
if (!command.UserRoles.Any())
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||
}
|
||||
//if (userResult != null)
|
||||
//{
|
||||
// if (!command.UserRoles.Any())
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
|
||||
var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
|
||||
userResult.Edit(command.Fullname, command.Username, command.Mobile, userRoles, command.IsProgramManagerUser);
|
||||
await _pmUserRepository.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر");
|
||||
}
|
||||
//var parameters = new EditUserCommand(
|
||||
// command.Fullname,
|
||||
// command.Username,
|
||||
// command.Mobile,
|
||||
// account.id,
|
||||
// command.UserRoles,
|
||||
// command.IsProgramManagerUser
|
||||
//);
|
||||
//var url = "api/user/edit";
|
||||
//var response = InternalApiCaller.PostAsync<EditUserCommand, ApiResponse>(
|
||||
// url,
|
||||
// key,
|
||||
// parameters
|
||||
//);
|
||||
// var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
|
||||
// userResult.Edit(command.Fullname, command.Username, command.Mobile, userRoles, command.IsProgramManagerUser);
|
||||
// await _pmUserRepository.SaveChangesAsync();
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر");
|
||||
// }
|
||||
// //var parameters = new EditUserCommand(
|
||||
// // command.Fullname,
|
||||
// // command.Username,
|
||||
// // command.Mobile,
|
||||
// // account.id,
|
||||
// // command.UserRoles,
|
||||
// // command.IsProgramManagerUser
|
||||
// //);
|
||||
// //var url = "api/user/edit";
|
||||
// //var response = InternalApiCaller.PostAsync<EditUserCommand, ApiResponse>(
|
||||
// // url,
|
||||
// // key,
|
||||
// // parameters
|
||||
// //);
|
||||
|
||||
//if (!response.Success)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Error);
|
||||
// //if (!response.Success)
|
||||
// //{
|
||||
// // _unitOfWork.RollbackAccountContext();
|
||||
// // return operation.Failed(response.Error);
|
||||
|
||||
//}
|
||||
// //}
|
||||
|
||||
//if (!response.Result.isSuccess)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Error);
|
||||
//}
|
||||
// //if (!response.Result.isSuccess)
|
||||
// //{
|
||||
// // _unitOfWork.RollbackAccountContext();
|
||||
// // return operation.Failed(response.Error);
|
||||
// //}
|
||||
|
||||
}
|
||||
else //اگر کاربر قبلا ایجاد نشده
|
||||
{
|
||||
//اگر تیک فعالیت در پروگرام منیجر روشن بود
|
||||
if (command.IsProgramManagerUser)
|
||||
{
|
||||
if (!command.UserRoles.Any())
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||
}
|
||||
//}
|
||||
//else //اگر کاربر قبلا ایجاد نشده
|
||||
//{
|
||||
// //اگر تیک فعالیت در پروگرام منیجر روشن بود
|
||||
// if (command.IsProgramManagerUser)
|
||||
// {
|
||||
// if (!command.UserRoles.Any())
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||
// }
|
||||
|
||||
if (_pmUserRepository.Exists(x => x.FullName == command.Fullname))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("نام و خانوادگی تکراری است");
|
||||
}
|
||||
// if (_pmUserRepository.Exists(x => x.FullName == command.Fullname))
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("نام و خانوادگی تکراری است");
|
||||
// }
|
||||
|
||||
if (_pmUserRepository.Exists(x => x.UserName == command.Username))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("نام کاربری تکراری است");
|
||||
}
|
||||
// if (_pmUserRepository.Exists(x => x.UserName == command.Username))
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("نام کاربری تکراری است");
|
||||
// }
|
||||
|
||||
if (_pmUserRepository.Exists(x => !string.IsNullOrWhiteSpace(x.Mobile) && x.Mobile == command.Mobile))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("این شماره همراه قبلا به فرد دیگری اختصاص داده شده است");
|
||||
}
|
||||
// if (_pmUserRepository.Exists(x => !string.IsNullOrWhiteSpace(x.Mobile) && x.Mobile == command.Mobile))
|
||||
// {
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("این شماره همراه قبلا به فرد دیگری اختصاص داده شده است");
|
||||
// }
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
|
||||
var create = new PmUser(command.Fullname, command.Username, account.Password, command.Mobile,
|
||||
null, account.id, userRoles);
|
||||
await _pmUserRepository.CreateAsync(create);
|
||||
await _pmUserRepository.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// try
|
||||
// {
|
||||
// var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
|
||||
// var create = new PmUser(command.Fullname, command.Username, account.Password, command.Mobile,
|
||||
// null, account.id, userRoles);
|
||||
// await _pmUserRepository.CreateAsync(create);
|
||||
// await _pmUserRepository.SaveChangesAsync();
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر");
|
||||
}
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر");
|
||||
// }
|
||||
|
||||
|
||||
//var parameters = new CreateProgramManagerUser(
|
||||
// command.Fullname,
|
||||
// command.Username,
|
||||
// account.Password,
|
||||
// command.Mobile,
|
||||
// command.Email,
|
||||
// account.id,
|
||||
// command.UserRoles
|
||||
//);
|
||||
// //var parameters = new CreateProgramManagerUser(
|
||||
// // command.Fullname,
|
||||
// // command.Username,
|
||||
// // account.Password,
|
||||
// // command.Mobile,
|
||||
// // command.Email,
|
||||
// // account.id,
|
||||
// // command.UserRoles
|
||||
// //);
|
||||
|
||||
//var url = "api/user/Create";
|
||||
// //var url = "api/user/Create";
|
||||
|
||||
|
||||
//var response = InternalApiCaller.PostAsync<CreateProgramManagerUser, ApiResponse>(
|
||||
// url,
|
||||
// key,
|
||||
// parameters
|
||||
//);
|
||||
// //var response = InternalApiCaller.PostAsync<CreateProgramManagerUser, ApiResponse>(
|
||||
// // url,
|
||||
// // key,
|
||||
// // parameters
|
||||
// //);
|
||||
|
||||
//if (!response.Success)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Error);
|
||||
// //if (!response.Success)
|
||||
// //{
|
||||
// // _unitOfWork.RollbackAccountContext();
|
||||
// // return operation.Failed(response.Error);
|
||||
|
||||
//}
|
||||
// //}
|
||||
|
||||
//if (!response.Result.isSuccess)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Error);
|
||||
//}
|
||||
}
|
||||
// //if (!response.Result.isSuccess)
|
||||
// //{
|
||||
// // _unitOfWork.RollbackAccountContext();
|
||||
// // return operation.Failed(response.Error);
|
||||
// //}
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
_unitOfWork.CommitAccountContext();
|
||||
return operation.Succcedded();
|
||||
@@ -919,7 +919,7 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
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, false);
|
||||
}
|
||||
_accountRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
|
||||
Reference in New Issue
Block a user