Fisxd Lost codes 1
This commit is contained in:
@@ -22,5 +22,6 @@ namespace AccountManagement.Application.Contracts.Account
|
||||
public int PositionValue { get; set; }
|
||||
public long PositionId { get; set; }
|
||||
#endregion
|
||||
public string AdminAreaPermission { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using AccountManagement.Domain.AccountAgg;
|
||||
@@ -416,20 +417,36 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
public AccountLeftWorkViewModel WorkshopList(long accountId)
|
||||
{
|
||||
string fullName = _accountRepository.GetById(accountId).Fullname;
|
||||
var list =_accountLeftworkRepository.WorkshopList(accountId);
|
||||
var lefts = _accountLeftworkRepository.GetByAccountId(accountId);
|
||||
var result = new AccountLeftWorkViewModel
|
||||
{
|
||||
AccountId = accountId,
|
||||
AccountFullName = fullName,
|
||||
StartDateFa = lefts.StartWorkFa,
|
||||
LeftDateFa = lefts.LeftWorkFa,
|
||||
WorkshopAccountlist = list,
|
||||
};
|
||||
string fullname = this._accountRepository.GetById(accountId).Fullname;
|
||||
List<WorkshopAccountlistViewModel> source = this._accountLeftworkRepository.WorkshopList(accountId);
|
||||
List<long> userWorkshopIds = source.Select<WorkshopAccountlistViewModel, long>((Func<WorkshopAccountlistViewModel, long>)(x => x.WorkshopId)).ToList<long>();
|
||||
List<WorkshopSelectList> allWorkshops = this._accountLeftworkRepository.GetAllWorkshops();
|
||||
List<AccountViewModel> accountSelectList = this._accountRepository.GetAdminAccountSelectList();
|
||||
(string StartWorkFa, string LeftWorkFa) byAccountId = this._accountLeftworkRepository.GetByAccountId(accountId);
|
||||
return new AccountLeftWorkViewModel()
|
||||
{
|
||||
AccountId = accountId,
|
||||
AccountFullName = fullname,
|
||||
StartDateFa = byAccountId.StartWorkFa,
|
||||
LeftDateFa = byAccountId.LeftWorkFa,
|
||||
WorkshopAccountlist = source,
|
||||
WorkshopSelectList = new SelectList((IEnumerable)allWorkshops.Where<WorkshopSelectList>((Func<WorkshopSelectList, bool>)(x => !userWorkshopIds.Contains(x.Id))), "Id", "WorkshopFullName"),
|
||||
AccountSelectList = new SelectList((IEnumerable)accountSelectList, "Id", "Fullname")
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
public OperationResult SaveWorkshopAccount(
|
||||
List<WorkshopAccountlistViewModel> workshopAccountList,
|
||||
string startDate,
|
||||
string leftDate,
|
||||
long accountId)
|
||||
{
|
||||
return this._accountLeftworkRepository.SaveWorkshopAccount(workshopAccountList, startDate, leftDate, accountId);
|
||||
}
|
||||
|
||||
public OperationResult CreateNewWorkshopAccount(long currentAccountId, long newAccountId)
|
||||
{
|
||||
return this._accountLeftworkRepository.CopyWorkshopToNewAccount(currentAccountId, newAccountId);
|
||||
}
|
||||
|
||||
public List<AccountViewModel> AccountsForAssign(long accountId)
|
||||
|
||||
@@ -88,7 +88,8 @@ public class AccountRepository : RepositoryBase<long, Account>, IAccountReposito
|
||||
RoleId = x.RoleId,
|
||||
Mobile = x.Mobile,
|
||||
CreationDateGr = x.CreationDate,
|
||||
IsActiveString = x.IsActiveString
|
||||
IsActiveString = x.IsActiveString,
|
||||
AdminAreaPermission = x.AdminAreaPermission
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,10 @@ public interface IWorkshopRepository : IRepository<long, Workshop>
|
||||
|
||||
#endregion
|
||||
|
||||
#region Vafa
|
||||
|
||||
List<PrintListWorkshop> PrintWorkshopList(WorkshopSearchModel searchModel);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -52,5 +52,9 @@ public interface IWorkshopApplication
|
||||
|
||||
#endregion
|
||||
|
||||
#region Vafa
|
||||
|
||||
List<PrintListWorkshop> PrintWorkshopList(WorkshopSearchModel searchModel);
|
||||
|
||||
#endregion
|
||||
}
|
||||
74
CompanyManagment.App.Contracts/Workshop/PrintListWorkshop.cs
Normal file
74
CompanyManagment.App.Contracts/Workshop/PrintListWorkshop.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Employer;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Workshop;
|
||||
public class PrintListWorkshop
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string WorkshopName { get; set; }
|
||||
public string WorkshopSureName { get; set; }
|
||||
public string WorkshopFullName { get; set; }
|
||||
public string InsuranceCode { get; set; }
|
||||
|
||||
public string EmployerName { get; set; }
|
||||
|
||||
public string TypeOfOwnership { get; set; }
|
||||
|
||||
public string ArchiveCode { get; set; }
|
||||
|
||||
public string AgentName { get; set; }
|
||||
|
||||
public string AgentPhone { get; set; }
|
||||
|
||||
public string State { get; set; }
|
||||
|
||||
public string City { get; set; }
|
||||
|
||||
public string Address { get; set; }
|
||||
|
||||
public string TypeOfInsuranceSend { get; set; }
|
||||
|
||||
public string TypeOfContract { get; set; }
|
||||
public long EmpId { get; set; }
|
||||
public string ContractTerm { get; set; }
|
||||
public string IsActiveString { get; set; }
|
||||
public string AgreementNumber { get; set; }
|
||||
public bool FixedSalary { get; set; }
|
||||
public string Population { get; set; }
|
||||
public long? InsuranceJobId { get; set; }
|
||||
public string ZoneName { get; set; }
|
||||
public string SearchResultTitle { get; set; }
|
||||
public bool TotalPaymentHide { get; set; }
|
||||
public bool HasLeftwork { get; set; }
|
||||
public bool HasBlockContractingParty { get; set; }
|
||||
public bool IsClassified { get; set; }
|
||||
public List<EmployerViewModel> EmpList { get; set; }
|
||||
public List<EmployeeViewModel> EmployeeList { get; set; }
|
||||
public List<LeftWorkViewModel> ContractLeftWorks { get; set; }
|
||||
public List<LeftWorkViewModel> CheckoutLeftWorks { get; set; }
|
||||
public long ContractingPartId { get; set; }
|
||||
public int PersonnelCount { get; set; }
|
||||
//نحوه محاسبه مزد مرخصی
|
||||
public string ComputeOptions { get; set; }
|
||||
//نحوه محاسبه عیدی
|
||||
public string BonusesOptions { get; set; }
|
||||
|
||||
//نحوه محاسبه سنوات
|
||||
public string YearsOptions { get; set; }
|
||||
//نگهدارنده وضعیت قراردادهای گذشته
|
||||
public bool IsOldContract { get; set; }
|
||||
|
||||
#region Vafa
|
||||
|
||||
public List<AccountViewModel> AccountsFullName { get; set; }
|
||||
public string AccountFullName { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -43,5 +43,7 @@ public class WorkshopSearchModel
|
||||
//نگهدارنده وضعیت قراردادهای گذشته
|
||||
public bool IsOldContract { get; set; }
|
||||
public List<EmployerViewModel> Employers { get; set; }
|
||||
|
||||
public List<long> AccountIds { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
|
||||
}
|
||||
@@ -619,6 +619,11 @@ public class WorkshopAppliction : IWorkshopApplication
|
||||
return _workshopRepository.ActiveAll(id);
|
||||
}
|
||||
|
||||
public List<PrintListWorkshop> PrintWorkshopList(WorkshopSearchModel searchModel)
|
||||
{
|
||||
return _workshopRepository.PrintWorkshopList(searchModel);
|
||||
}
|
||||
|
||||
//public List<ConnectedPersonnelViewModel> GetConnectedPersonnelsForMain(long workshopId)
|
||||
//{
|
||||
// return _workshopRepository.GetConnectedPersonnelsForMain(workshopId);
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using Company.Domain.WorkshopAccountAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
@@ -13,6 +14,8 @@ using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Employer;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Identity.Client;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -22,12 +25,14 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
||||
private readonly AccountContext _accountContext;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IPasswordHasher _passwordHasher;
|
||||
public WorkshopRepository(CompanyContext context, AccountContext accountContext, IAuthHelper authHelper, IPasswordHasher passwordHasher) : base(context)
|
||||
private readonly IWorkshopAccountRepository _workshopAccountRepository;
|
||||
public WorkshopRepository(CompanyContext context, AccountContext accountContext, IAuthHelper authHelper, IPasswordHasher passwordHasher, IWorkshopAccountRepository workshopAccountRepository) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_accountContext = accountContext;
|
||||
_authHelper = authHelper;
|
||||
_passwordHasher = passwordHasher;
|
||||
_workshopAccountRepository = workshopAccountRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -1087,121 +1092,137 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
||||
|
||||
public List<WorkshopViewModel> SearchForMain(WorkshopSearchModel searchModel)
|
||||
{
|
||||
var leftWorkInsuranceList = _context.LeftWorkInsuranceList.Select(x => x.WorkshopId).ToList();
|
||||
var leftWorkList = _context.LeftWorkList.Select(x => x.WorkshopId).ToList();
|
||||
var AcountID = _authHelper.CurrentAccountId();
|
||||
var workshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == AcountID).Select(x => x.WorkshopId).ToList();
|
||||
var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "true").Select(x=>x.id).ToList();
|
||||
var query = _context.Workshops.Include(x => x.WorkshopEmployers)
|
||||
.Select(x => new WorkshopViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopName = x.WorkshopName,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
//EmployerName = x.WorkshopEmployers.
|
||||
WorkshopSureName = x.WorkshopSureName,
|
||||
WorkshopFullName = x.WorkshopFullName,
|
||||
TypeOfOwnership = x.TypeOfOwnership,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
AgentName = x.AgentName,
|
||||
AgentPhone = x.AgentPhone,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
TypeOfInsuranceSend = x.TypeOfInsuranceSend,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
IsActiveString = x.IsActiveString,
|
||||
ContractTerm = x.ContractTerm,
|
||||
AgreementNumber = x.AgreementNumber,
|
||||
FixedSalary = x.FixedSalary,
|
||||
Population = x.Population,
|
||||
InsuranceJobId = x.InsuranceJobId,
|
||||
ZoneName = x.ZoneName,
|
||||
TotalPaymentHide = x.TotalPaymentHide,
|
||||
HasBlockContractingParty = false,
|
||||
IsClassified = x.IsClassified,
|
||||
HasLeftwork = (leftWorkInsuranceList.Contains(x.id) || leftWorkList.Contains(x.id)),
|
||||
EmpList = x.WorkshopEmployers.Select(y => new EmployerViewModel()
|
||||
{
|
||||
Id = y.EmployerId, FullName = y.Employer.FullName,ContractingPartyID = y.Employer.ContractingPartyId
|
||||
}).ToList(),
|
||||
}).Where(e => workshopIds.Contains(e.Id));
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName))
|
||||
query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName));
|
||||
var leftWorkInsuranceList = _context.LeftWorkInsuranceList.Select(x => x.WorkshopId).ToList();
|
||||
var leftWorkList = _context.LeftWorkList.Select(x => x.WorkshopId).ToList();
|
||||
var AcountID = _authHelper.CurrentAccountId();
|
||||
var workshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == AcountID).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.InsuranceCode))
|
||||
query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode));
|
||||
if (searchModel.AccountIds != null && searchModel.AccountIds.Any())
|
||||
workshopIds = workshopIds.Where(x => searchModel.AccountIds.Contains(x.AccountId)).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ArchiveCode))
|
||||
query = query.Where(x => x.ArchiveCode == searchModel.ArchiveCode);
|
||||
var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "true").Select(x => x.id).ToList();
|
||||
var query = _context.Workshops.Include(x => x.WorkshopEmployers)
|
||||
.Select(x => new WorkshopViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopName = x.WorkshopName,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
//EmployerName = x.WorkshopEmployers.
|
||||
WorkshopSureName = x.WorkshopSureName,
|
||||
WorkshopFullName = x.WorkshopFullName,
|
||||
TypeOfOwnership = x.TypeOfOwnership,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
AgentName = x.AgentName,
|
||||
AgentPhone = x.AgentPhone,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
TypeOfInsuranceSend = x.TypeOfInsuranceSend,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
IsActiveString = x.IsActiveString,
|
||||
ContractTerm = x.ContractTerm,
|
||||
AgreementNumber = x.AgreementNumber,
|
||||
FixedSalary = x.FixedSalary,
|
||||
Population = x.Population,
|
||||
InsuranceJobId = x.InsuranceJobId,
|
||||
ZoneName = x.ZoneName,
|
||||
TotalPaymentHide = x.TotalPaymentHide,
|
||||
HasBlockContractingParty = false,
|
||||
IsClassified = x.IsClassified,
|
||||
HasLeftwork = (leftWorkInsuranceList.Contains(x.id) || leftWorkList.Contains(x.id)),
|
||||
EmpList = x.WorkshopEmployers.Select(y => new EmployerViewModel()
|
||||
{
|
||||
Id = y.EmployerId,
|
||||
FullName = y.Employer.FullName,
|
||||
ContractingPartyID = y.Employer.ContractingPartyId
|
||||
}).ToList(),
|
||||
}).Where(e => workshopIds.Select(a => a.WorkshopId).Contains(e.Id));
|
||||
if (searchModel.AccountId > 0)
|
||||
{
|
||||
var res = _workshopAccountRepository.GetList(searchModel.AccountId).Select(x => x.WorkshopId).ToList();
|
||||
query = query.Where(x => res.Contains(x.Id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName))
|
||||
query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName));
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName))
|
||||
query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ContractTerm))
|
||||
query = query.Where(x => x.ContractTerm == searchModel.ContractTerm);
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.InsuranceCode))
|
||||
query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.TypeOfContract))
|
||||
query = query.Where(x => x.TypeOfContract == searchModel.TypeOfContract);
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ArchiveCode))
|
||||
query = query.Where(x => x.ArchiveCode == searchModel.ArchiveCode);
|
||||
|
||||
if (searchModel.EmployerId != 0)
|
||||
{
|
||||
var emp = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId)
|
||||
.Select(x => x.WorkshopId).ToList();
|
||||
query = query.Where(x => emp.Contains(x.Id));
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName))
|
||||
query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName));
|
||||
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ContractTerm))
|
||||
query = query.Where(x => x.ContractTerm == searchModel.ContractTerm);
|
||||
|
||||
#region NewByHeydari
|
||||
if (!string.IsNullOrEmpty(searchModel.EmployerLName))
|
||||
{
|
||||
var employerIds = _context.Employers.Where(x =>
|
||||
(!string.IsNullOrEmpty(x.FName) && x.FName.Contains(searchModel.EmployerLName)) ||
|
||||
(!string.IsNullOrEmpty(x.LName) && x.LName.Contains(searchModel.EmployerLName))).Select(x => x.id);
|
||||
var workshopIds2 = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList();
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.TypeOfContract))
|
||||
query = query.Where(x => x.TypeOfContract == searchModel.TypeOfContract);
|
||||
|
||||
query = query.Where(x => workshopIds2.Contains(x.Id));
|
||||
}
|
||||
if (searchModel.EmployerId != 0)
|
||||
{
|
||||
var emp = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId)
|
||||
.Select(x => x.WorkshopId).ToList();
|
||||
query = query.Where(x => emp.Contains(x.Id));
|
||||
|
||||
if (!string.IsNullOrEmpty(searchModel.State))
|
||||
{
|
||||
query = query.Where(x => x.State == searchModel.State);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(searchModel.City))
|
||||
{
|
||||
query = query.Where(x => x.City == searchModel.City);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.WorkshopFullName))
|
||||
query = query.Where(x => x.WorkshopFullName.Contains(searchModel.WorkshopFullName) || x.ArchiveCode.Contains(searchModel.WorkshopFullName));
|
||||
#endregion
|
||||
}
|
||||
|
||||
if (searchModel.Id != 0)
|
||||
query = query.Where(x => x.Id == searchModel.Id);
|
||||
#region NewByHeydari
|
||||
if (!string.IsNullOrEmpty(searchModel.EmployerLName))
|
||||
{
|
||||
var employerIds = _context.Employers.Where(x =>
|
||||
(!string.IsNullOrEmpty(x.FName) && x.FName.Contains(searchModel.EmployerLName)) ||
|
||||
(!string.IsNullOrEmpty(x.LName) && x.LName.Contains(searchModel.EmployerLName))).Select(x => x.id);
|
||||
var workshopIds2 = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList();
|
||||
|
||||
if (searchModel.IsActiveString == null)
|
||||
{
|
||||
query = query.Where(x => x.IsActiveString == "true");
|
||||
}
|
||||
query = query.Where(x => workshopIds2.Contains(x.Id));
|
||||
}
|
||||
|
||||
if (searchModel.IsActiveString == "false")
|
||||
{
|
||||
query = query.Where(x => x.IsActiveString == "false");
|
||||
}
|
||||
else if (searchModel.IsActiveString == "both")
|
||||
{
|
||||
query = query.Where(x => x.IsActiveString == "false" || x.IsActiveString == "true");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(searchModel.State))
|
||||
{
|
||||
query = query.Where(x => x.State == searchModel.State);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(searchModel.City))
|
||||
{
|
||||
query = query.Where(x => x.City == searchModel.City);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.WorkshopFullName))
|
||||
query = query.Where(x => x.WorkshopFullName.Contains(searchModel.WorkshopFullName) || x.ArchiveCode.Contains(searchModel.WorkshopFullName));
|
||||
#endregion
|
||||
|
||||
var list = query.OrderByDescending(x => x.Id).ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var empContractingPartyIds = item.EmpList.Select(x => x.ContractingPartyID).ToList();
|
||||
item.HasBlockContractingParty = blockContractingPartyIds.Intersect(empContractingPartyIds).Any();
|
||||
|
||||
}
|
||||
if (searchModel.Id != 0)
|
||||
query = query.Where(x => x.Id == searchModel.Id);
|
||||
|
||||
return list;
|
||||
}
|
||||
if (searchModel.IsActiveString == null)
|
||||
{
|
||||
query = query.Where(x => x.IsActiveString == "true");
|
||||
}
|
||||
|
||||
if (searchModel.IsActiveString == "false")
|
||||
{
|
||||
query = query.Where(x => x.IsActiveString == "false");
|
||||
}
|
||||
else if (searchModel.IsActiveString == "both")
|
||||
{
|
||||
query = query.Where(x => x.IsActiveString == "false" || x.IsActiveString == "true");
|
||||
}
|
||||
|
||||
var list = query.OrderByDescending(x => x.Id).ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var empContractingPartyIds = item.EmpList.Select(x => x.ContractingPartyID).ToList();
|
||||
item.HasBlockContractingParty = blockContractingPartyIds.Intersect(empContractingPartyIds).Any();
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public OperationResult DeActiveAll(long id)
|
||||
{
|
||||
@@ -1261,5 +1282,182 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
#region vafa
|
||||
|
||||
|
||||
public List<PrintListWorkshop> PrintWorkshopList(WorkshopSearchModel searchModel)
|
||||
{
|
||||
var leftWorkInsuranceList = _context.LeftWorkInsuranceList.Select(x => x.WorkshopId).ToList();
|
||||
var leftWorkList = _context.LeftWorkList.Select(x => x.WorkshopId).ToList();
|
||||
var AcountID = _authHelper.CurrentAccountId();
|
||||
var workshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == AcountID).ToList();
|
||||
|
||||
if (searchModel.AccountIds != null && searchModel.AccountIds.Any())
|
||||
workshopIds = workshopIds.Where(x => searchModel.AccountIds.Contains(x.AccountId)).ToList();
|
||||
|
||||
var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "true").Select(x => x.id).ToList();
|
||||
var query = _context.Workshops.Include(x => x.WorkshopEmployers)
|
||||
.Select(x => new WorkshopViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopName = x.WorkshopName,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
//EmployerName = x.WorkshopEmployers.
|
||||
WorkshopSureName = x.WorkshopSureName,
|
||||
WorkshopFullName = x.WorkshopFullName,
|
||||
TypeOfOwnership = x.TypeOfOwnership,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
AgentName = x.AgentName,
|
||||
AgentPhone = x.AgentPhone,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
TypeOfInsuranceSend = x.TypeOfInsuranceSend,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
IsActiveString = x.IsActiveString,
|
||||
ContractTerm = x.ContractTerm,
|
||||
AgreementNumber = x.AgreementNumber,
|
||||
FixedSalary = x.FixedSalary,
|
||||
Population = x.Population,
|
||||
InsuranceJobId = x.InsuranceJobId,
|
||||
ZoneName = x.ZoneName,
|
||||
TotalPaymentHide = x.TotalPaymentHide,
|
||||
HasBlockContractingParty = false,
|
||||
IsClassified = x.IsClassified,
|
||||
HasLeftwork = (leftWorkInsuranceList.Contains(x.id) || leftWorkList.Contains(x.id)),
|
||||
EmpList = x.WorkshopEmployers.Select(y => new EmployerViewModel()
|
||||
{
|
||||
Id = y.EmployerId,
|
||||
FullName = y.Employer.FullName,
|
||||
ContractingPartyID = y.Employer.ContractingPartyId
|
||||
}).ToList(),
|
||||
}).Where(e => workshopIds.Select(a => a.WorkshopId).Contains(e.Id));
|
||||
if (searchModel.AccountId > 0)
|
||||
{
|
||||
var res = _workshopAccountRepository.GetList(searchModel.AccountId).Select(x => x.WorkshopId).ToList();
|
||||
query = query.Where(x => res.Contains(x.Id));
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName))
|
||||
query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.InsuranceCode))
|
||||
query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ArchiveCode))
|
||||
query = query.Where(x => x.ArchiveCode == searchModel.ArchiveCode);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName))
|
||||
query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ContractTerm))
|
||||
query = query.Where(x => x.ContractTerm == searchModel.ContractTerm);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.TypeOfContract))
|
||||
query = query.Where(x => x.TypeOfContract == searchModel.TypeOfContract);
|
||||
|
||||
if (searchModel.EmployerId != 0)
|
||||
{
|
||||
var emp = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId)
|
||||
.Select(x => x.WorkshopId).ToList();
|
||||
query = query.Where(x => emp.Contains(x.Id));
|
||||
|
||||
}
|
||||
|
||||
#region NewByHeydari
|
||||
if (!string.IsNullOrEmpty(searchModel.EmployerLName))
|
||||
{
|
||||
var employerIds = _context.Employers.Where(x =>
|
||||
(!string.IsNullOrEmpty(x.FName) && x.FName.Contains(searchModel.EmployerLName)) ||
|
||||
(!string.IsNullOrEmpty(x.LName) && x.LName.Contains(searchModel.EmployerLName))).Select(x => x.id);
|
||||
var workshopIds2 = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList();
|
||||
|
||||
query = query.Where(x => workshopIds2.Contains(x.Id));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(searchModel.State))
|
||||
{
|
||||
query = query.Where(x => x.State == searchModel.State);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(searchModel.City))
|
||||
{
|
||||
query = query.Where(x => x.City == searchModel.City);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.WorkshopFullName))
|
||||
query = query.Where(x => x.WorkshopFullName.Contains(searchModel.WorkshopFullName) || x.ArchiveCode.Contains(searchModel.WorkshopFullName));
|
||||
#endregion
|
||||
|
||||
if (searchModel.Id != 0)
|
||||
query = query.Where(x => x.Id == searchModel.Id);
|
||||
|
||||
if (searchModel.IsActiveString == null)
|
||||
{
|
||||
query = query.Where(x => x.IsActiveString == "true");
|
||||
}
|
||||
|
||||
if (searchModel.IsActiveString == "false")
|
||||
{
|
||||
query = query.Where(x => x.IsActiveString == "false");
|
||||
}
|
||||
else if (searchModel.IsActiveString == "both")
|
||||
{
|
||||
query = query.Where(x => x.IsActiveString == "false" || x.IsActiveString == "true");
|
||||
}
|
||||
|
||||
var rawList = query.OrderByDescending(x => x.Id).ToList();
|
||||
var list = rawList.Select(x => new PrintListWorkshop()
|
||||
{
|
||||
Id = x.Id,
|
||||
WorkshopName = x.WorkshopName,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
WorkshopSureName = x.WorkshopSureName,
|
||||
WorkshopFullName = x.WorkshopFullName,
|
||||
TypeOfOwnership = x.TypeOfOwnership,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
AgentName = x.AgentName,
|
||||
AgentPhone = x.AgentPhone,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
TypeOfInsuranceSend = x.TypeOfInsuranceSend,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
IsActiveString = x.IsActiveString,
|
||||
ContractTerm = x.ContractTerm,
|
||||
AgreementNumber = x.AgreementNumber,
|
||||
FixedSalary = x.FixedSalary,
|
||||
Population = x.Population,
|
||||
InsuranceJobId = x.InsuranceJobId,
|
||||
ZoneName = x.ZoneName,
|
||||
TotalPaymentHide = x.TotalPaymentHide,
|
||||
HasBlockContractingParty = false,
|
||||
IsClassified = x.IsClassified,
|
||||
HasLeftwork = x.HasLeftwork,
|
||||
EmpList = x.EmpList,
|
||||
AccountFullName = searchModel.AccountId != 0 ? _accountContext.Accounts.FirstOrDefault(oneAc => oneAc.id == searchModel.AccountId)?.Fullname : "",
|
||||
AccountsFullName = (searchModel.AccountIds != null && searchModel.AccountIds.Any())
|
||||
? _accountContext.Accounts
|
||||
.Where(ac => searchModel.AccountIds.Contains(ac.id))
|
||||
.Select(account => new AccountViewModel
|
||||
{
|
||||
Id = account.id,
|
||||
Fullname = account.Fullname
|
||||
}).ToList()
|
||||
: new List<AccountViewModel>(),
|
||||
}).ToList();
|
||||
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
var empContractingPartyIds = item.EmpList.Select(x => x.ContractingPartyID).ToList();
|
||||
item.HasBlockContractingParty = blockContractingPartyIds.Intersect(empContractingPartyIds).Any();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -217,4 +217,42 @@ public class IndexModel : PageModel
|
||||
|
||||
return Partial("AccountLeftWork", res);
|
||||
}
|
||||
|
||||
public IActionResult OnPostCreateAccountLeftWork(
|
||||
List<WorkshopAccountlistViewModel> workshopAccountlistViewModel,
|
||||
string startDate,
|
||||
string leftDate,
|
||||
long accountId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(startDate))
|
||||
return (IActionResult)new JsonResult((object)new
|
||||
{
|
||||
isSuccess = false,
|
||||
mess = "تاریخ شروع بکار خالی است"
|
||||
});
|
||||
OperationResult operationResult = this._accountApplication.SaveWorkshopAccount(workshopAccountlistViewModel, startDate, leftDate, accountId);
|
||||
return operationResult.IsSuccedded ? (IActionResult)new JsonResult((object)new
|
||||
{
|
||||
isSuccess = true,
|
||||
mess = operationResult.Message
|
||||
}) : (IActionResult)new JsonResult((object)new
|
||||
{
|
||||
isSuccess = false,
|
||||
mess = operationResult.Message
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetCopyWorkshopToNewAccount(long currentAccountId, long newAccountId)
|
||||
{
|
||||
OperationResult newWorkshopAccount = this._accountApplication.CreateNewWorkshopAccount(currentAccountId, newAccountId);
|
||||
return newWorkshopAccount.IsSuccedded ? (IActionResult)new JsonResult((object)new
|
||||
{
|
||||
isSuccess = true
|
||||
}) : (IActionResult)new JsonResult((object)new
|
||||
{
|
||||
isSuccess = false,
|
||||
message = newWorkshopAccount.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using AccountManagement.Domain.AccountAgg;
|
||||
using Company.Domain.empolyerAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
@@ -37,14 +38,17 @@ public class IndexModel : PageModel
|
||||
private readonly IWorkshopRepository _workshopRepository;
|
||||
private readonly IYearlySalaryApplication _yearlySalaryApplication;
|
||||
private readonly IZoneApplication _zoneApplication;
|
||||
public SelectList Employers;
|
||||
public string LName;
|
||||
public WorkshopSearchModel SearchModel;
|
||||
public string WorkshopFullName;
|
||||
public SelectList WorkshopList;
|
||||
public List<WorkshopViewModel> Workshops;
|
||||
[TempData]
|
||||
public string Message { get; set; }
|
||||
public WorkshopSearchModel SearchModel;
|
||||
public List<WorkshopViewModel> Workshops;
|
||||
public SelectList WorkshopList;
|
||||
public SelectList Employers;
|
||||
public string LName;
|
||||
public string WorkshopFullName;
|
||||
public List<AccountViewModel> AccountList;
|
||||
|
||||
public IndexModel(IWorkshopApplication workshopApplication, IEmployerApplication employerApplication,
|
||||
public IndexModel(IWorkshopApplication workshopApplication, IEmployerApplication employerApplication,
|
||||
IEmployerRepository employerRepository, IWorkshopRepository workshopRepository,
|
||||
IAccountRepository accountRepository, IZoneApplication zoneApplication,
|
||||
IInsuranceJobApplication insuranceJobApplication, IJobApplication jobApplication,
|
||||
@@ -68,22 +72,34 @@ public class IndexModel : PageModel
|
||||
_yearlySalaryApplication = yearlySalaryApplication;
|
||||
}
|
||||
|
||||
[TempData] public string Message { get; set; }
|
||||
|
||||
|
||||
public void OnGet(WorkshopSearchModel searchModel)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(searchModel.EmployerLName)
|
||||
&& string.IsNullOrWhiteSpace(searchModel.WorkshopFullName)
|
||||
&& string.IsNullOrWhiteSpace(searchModel.InsuranceCode))
|
||||
Workshops = _workshopApplication.SearchForMain(searchModel)
|
||||
.OrderByDescending(x => x.HasBlockContractingParty).Take(100).ToList();
|
||||
else
|
||||
Workshops = _workshopApplication.SearchForMain(searchModel)
|
||||
.OrderByDescending(x => x.HasBlockContractingParty).ToList();
|
||||
//if (string.IsNullOrWhiteSpace(searchModel.EmployerLName)
|
||||
// && string.IsNullOrWhiteSpace(searchModel.WorkshopFullName)
|
||||
// && string.IsNullOrWhiteSpace(searchModel.InsuranceCode))
|
||||
// Workshops = _workshopApplication.SearchForMain(searchModel)
|
||||
// .OrderByDescending(x => x.HasBlockContractingParty).Take(100).ToList();
|
||||
//else
|
||||
// Workshops = _workshopApplication.SearchForMain(searchModel)
|
||||
// .OrderByDescending(x => x.HasBlockContractingParty).ToList();
|
||||
AccountList = _accountRepository.GetAccounts().Where(x => x.AdminAreaPermission == "true").ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.EmployerLName)
|
||||
|| !string.IsNullOrWhiteSpace(searchModel.WorkshopFullName)
|
||||
|| !string.IsNullOrWhiteSpace(searchModel.InsuranceCode) || searchModel.AccountId > 0)
|
||||
{
|
||||
Workshops = _workshopApplication.SearchForMain(searchModel).OrderByDescending(x => x.HasBlockContractingParty == true).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
Workshops = _workshopApplication.SearchForMain(searchModel).OrderByDescending(x => x.HasBlockContractingParty == true).Take(100).ToList();
|
||||
|
||||
//-----employer-----
|
||||
if (searchModel.EmployerId > 0)
|
||||
}
|
||||
|
||||
//-----employer-----
|
||||
if (searchModel.EmployerId > 0)
|
||||
{
|
||||
var employer = _EmployerApplication.GetDetails(searchModel.EmployerId);
|
||||
LName = employer.IsLegal == "حقیقی" ? employer.FName + " " + employer.LName : employer.LName;
|
||||
|
||||
@@ -294,7 +294,72 @@
|
||||
|
||||
@section Script{
|
||||
<script>'serviceWorker' in navigator && navigator.serviceWorker.register('/serviceworker')</script>
|
||||
<script>
|
||||
// if ('serviceWorker' in navigator) {
|
||||
// navigator.serviceWorker.register('/service-worker.js')
|
||||
// .then(function (registration) {
|
||||
// console.log('Service Worker registered with scope:', registration.scope);
|
||||
// alert('Service Worker registered with scope:' + registration.scope);
|
||||
// }).catch(function (error) {
|
||||
// console.log('Service Worker registration failed:', error);
|
||||
// alert('Service Worker registration failed:' + error);
|
||||
// });
|
||||
// }
|
||||
|
||||
if ('serviceWorker' in navigator && 'PushManager' in window) {
|
||||
window.addEventListener('beforeinstallprompt', (e) => {
|
||||
if (localStorage.getItem('pwaPromptDismissed') === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
const deferredPrompt = e;
|
||||
|
||||
const containerDiv = document.createElement('div');
|
||||
containerDiv.className = 'prompt-container';
|
||||
|
||||
const promptText = document.createElement('p');
|
||||
promptText.textContent = 'آیا می خواهید برنامه را نصب کنید؟';
|
||||
containerDiv.appendChild(promptText);
|
||||
|
||||
const yesButton = document.createElement('button');
|
||||
yesButton.textContent = 'بله';
|
||||
yesButton.classList.add('btn-grad');
|
||||
yesButton.style.background = '#84cc16';
|
||||
|
||||
const noButton = document.createElement('button');
|
||||
noButton.textContent = 'خیر';
|
||||
noButton.classList.add('btn-grad');
|
||||
noButton.style.background = '#ef4444';
|
||||
|
||||
yesButton.addEventListener('click', () => {
|
||||
deferredPrompt.prompt();
|
||||
|
||||
deferredPrompt.userChoice.then(choiceResult => {
|
||||
if (choiceResult.outcome === 'accepted') {
|
||||
console.log('App installed');
|
||||
} else {
|
||||
console.log('App installation declined');
|
||||
}
|
||||
|
||||
containerDiv.style.display = 'none';
|
||||
});
|
||||
});
|
||||
|
||||
noButton.addEventListener('click', () => {
|
||||
console.log('App installation declined');
|
||||
containerDiv.style.display = 'none';
|
||||
localStorage.setItem('pwaPromptDismissed', 'true');
|
||||
});
|
||||
|
||||
containerDiv.appendChild(yesButton);
|
||||
containerDiv.appendChild(noButton);
|
||||
|
||||
document.body.appendChild(containerDiv);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
//******************** رسپانسیو هنگام موبایل ********************
|
||||
$('#show_login').click(function () {
|
||||
|
||||
@@ -22,290 +22,280 @@ using AccountMangement.Infrastructure.EFCore.Repository;
|
||||
|
||||
namespace ServiceHost.Pages
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
|
||||
public string Mess { get; set; }
|
||||
[BindProperty]
|
||||
public string Username { get; set; }
|
||||
[BindProperty]
|
||||
public string Password { get; set; }
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
|
||||
private static Timer aTimer;
|
||||
public Login login;
|
||||
public AccountViewModel Search;
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly IAccountApplication _accountApplication;
|
||||
private readonly IGoogleRecaptcha _googleRecaptcha;
|
||||
private readonly ISmsService _smsService;
|
||||
private readonly IWorker _worker;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly ICameraAccountApplication _cameraAccountApplication;
|
||||
public IndexModel(ILogger<IndexModel> logger, IAccountApplication accountApplication, IGoogleRecaptcha googleRecaptcha, ISmsService smsService, IWorker worker, IAuthHelper authHelper, ICameraAccountApplication cameraAccountApplication)
|
||||
{
|
||||
_logger = logger;
|
||||
_accountApplication = accountApplication;
|
||||
_googleRecaptcha = googleRecaptcha;
|
||||
_smsService = smsService;
|
||||
_worker = worker;
|
||||
_authHelper = authHelper;
|
||||
_cameraAccountApplication = cameraAccountApplication;
|
||||
}
|
||||
public string Mess { get; set; }
|
||||
[BindProperty]
|
||||
public string Username { get; set; }
|
||||
[BindProperty]
|
||||
public string Password { get; set; }
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
|
||||
|
||||
if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
|
||||
|
||||
if (User.FindFirstValue("IsCamera") == "true")
|
||||
{
|
||||
return Redirect("/Camera");
|
||||
}
|
||||
if ((User.FindFirstValue("ClientAriaPermission") == "true") && (User.FindFirstValue("AdminAriaPermission") == "false"))
|
||||
{
|
||||
Console.WriteLine("client : " + User.FindFirstValue("ClientAriaPermission"));
|
||||
private static Timer aTimer;
|
||||
public Login login;
|
||||
public AccountViewModel Search;
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly IAccountApplication _accountApplication;
|
||||
private readonly IGoogleRecaptcha _googleRecaptcha;
|
||||
private readonly ISmsService _smsService;
|
||||
private readonly IWorker _worker;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly ICameraAccountApplication _cameraAccountApplication;
|
||||
public IndexModel(ILogger<IndexModel> logger, IAccountApplication accountApplication, IGoogleRecaptcha googleRecaptcha, ISmsService smsService, IWorker worker, IAuthHelper authHelper, ICameraAccountApplication cameraAccountApplication)
|
||||
{
|
||||
_logger = logger;
|
||||
_accountApplication = accountApplication;
|
||||
_googleRecaptcha = googleRecaptcha;
|
||||
_smsService = smsService;
|
||||
_worker = worker;
|
||||
_authHelper = authHelper;
|
||||
_cameraAccountApplication = cameraAccountApplication;
|
||||
}
|
||||
|
||||
return Redirect("/Client");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("admin : " + User.FindFirstValue("AdminAreaPermission"));
|
||||
return Redirect("/Admin");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
|
||||
public IActionResult OnPostLogin(Login command)
|
||||
{
|
||||
|
||||
var result= _accountApplication.Login(command);
|
||||
if (result.IsSuccedded)
|
||||
return RedirectToPage("/Admin");
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
if (User.FindFirstValue("IsCamera") == "true")
|
||||
{
|
||||
return Redirect("/Camera");
|
||||
}
|
||||
if ((User.FindFirstValue("ClientAriaPermission") == "true") && (User.FindFirstValue("AdminAreaPermission") == "false"))
|
||||
{
|
||||
return Redirect("/Client");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Redirect("/Admin");
|
||||
}
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
|
||||
ModelState.AddModelError("Username", "اطلاعات وارد شده اشتباه است");
|
||||
TempData["h"] = "n";
|
||||
Mess = result.Message;
|
||||
return null;
|
||||
public IActionResult OnPostLogin(Login command)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IActionResult OnPostEnter(Login command)
|
||||
{
|
||||
var result = _accountApplication.Login(command);
|
||||
if (result.IsSuccedded)
|
||||
{
|
||||
switch (result.SendId)
|
||||
{
|
||||
case 1:
|
||||
return Redirect("/Admin");
|
||||
break;
|
||||
case 2:
|
||||
return Redirect("/Client");
|
||||
break;
|
||||
case 3:
|
||||
return Redirect("/Camera");
|
||||
break;
|
||||
case 0:
|
||||
result.Message = "امکان ورود با این حساب کاربری وجود ندارد";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ModelState.AddModelError("Username", "اطلاعات وارد شده اشتباه است");
|
||||
Mess = result.Message;
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<JsonResult> OnPostCheckCaptcha(string response)
|
||||
{
|
||||
var result = await _googleRecaptcha.IsSatisfy(response);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
isNotRobot = result,
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnPostRegisterClient(string name, string user, string pass, string phone,string nationalcode)
|
||||
{
|
||||
var command = new RegisterAccount()
|
||||
{
|
||||
Fullname = name,
|
||||
Username = user,
|
||||
Password = pass,
|
||||
Mobile = phone,
|
||||
NationalCode = nationalcode,
|
||||
};
|
||||
var result = _accountApplication.RegisterClient(command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSucceded = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
public IActionResult OnGetLogout()
|
||||
{
|
||||
_accountApplication.Logout();
|
||||
return RedirectToPage("/Index");
|
||||
}
|
||||
var result = _accountApplication.Login(command);
|
||||
if (result.IsSuccedded)
|
||||
return RedirectToPage("/Admin");
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostCheckPhoneValid(string phone)
|
||||
{
|
||||
var result = _accountApplication.Search(new AccountSearchModel() { Mobile = phone }).FirstOrDefault();
|
||||
if (result == null)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = false,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
SendSms(phone);
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
});
|
||||
ModelState.AddModelError("Username", "اطلاعات وارد شده اشتباه است");
|
||||
TempData["h"] = "n";
|
||||
Mess = result.Message;
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void SendSms(string phone)
|
||||
{
|
||||
|
||||
var result = _accountApplication.Search(new AccountSearchModel() { Mobile = phone }).FirstOrDefault();
|
||||
if (result != null)
|
||||
{
|
||||
_accountApplication.SetVerifyCode(phone, result.Id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult OnPostWithMobile(string code, string phone)
|
||||
{
|
||||
var verfiyResult = _accountApplication.GetByVerifyCode(code, phone);
|
||||
if (verfiyResult != null)
|
||||
{
|
||||
|
||||
var result = _accountApplication.LoginWithMobile(verfiyResult.Id);
|
||||
if (result.IsSuccedded && result.SendId == 1)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
url = "/Admin",
|
||||
});
|
||||
}
|
||||
public IActionResult OnPostEnter(Login command)
|
||||
{
|
||||
var result = _accountApplication.Login(command);
|
||||
if (result.IsSuccedded)
|
||||
{
|
||||
switch (result.SendId)
|
||||
{
|
||||
case 1:
|
||||
return Redirect("/Admin");
|
||||
break;
|
||||
case 2:
|
||||
return Redirect("/Client");
|
||||
break;
|
||||
case 3:
|
||||
return Redirect("/Camera");
|
||||
break;
|
||||
case 0:
|
||||
result.Message = "امکان ورود با این حساب کاربری وجود ندارد";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (result.IsSuccedded && result.SendId == 2)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
url = "/Client",
|
||||
});
|
||||
}
|
||||
//ModelState.AddModelError("Username", "اطلاعات وارد شده اشتباه است");
|
||||
Mess = result.Message;
|
||||
return Page();
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<JsonResult> OnPostCheckCaptcha(string response)
|
||||
{
|
||||
var result = await _googleRecaptcha.IsSatisfy(response);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = false,
|
||||
});
|
||||
return new JsonResult(new
|
||||
{
|
||||
isNotRobot = result,
|
||||
|
||||
}
|
||||
public IActionResult OnPostVerify(string code, string phone)
|
||||
{
|
||||
var result = _accountApplication.GetByVerifyCode(code, phone);
|
||||
if (result != null)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
user = result.Username,
|
||||
verfyId = result.Id
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = false,
|
||||
});
|
||||
}
|
||||
}
|
||||
public IActionResult OnPostRegisterClient(string name, string user, string pass, string phone, string nationalcode)
|
||||
{
|
||||
var command = new RegisterAccount()
|
||||
{
|
||||
Fullname = name,
|
||||
Username = user,
|
||||
Password = pass,
|
||||
Mobile = phone,
|
||||
NationalCode = nationalcode,
|
||||
};
|
||||
var result = _accountApplication.RegisterClient(command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSucceded = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
public IActionResult OnGetLogout()
|
||||
{
|
||||
_accountApplication.Logout();
|
||||
return RedirectToPage("/Index");
|
||||
}
|
||||
|
||||
public IActionResult OnPostChangePass(long id, string username, string newpass)
|
||||
{
|
||||
var result = _accountApplication.GetByUserNameAndId(id, username);
|
||||
if (result != null)
|
||||
{
|
||||
var command = new ChangePassword()
|
||||
{
|
||||
Id = id,
|
||||
Password = newpass,
|
||||
RePassword = newpass
|
||||
};
|
||||
var finalResult = _accountApplication.ChangePassword(command);
|
||||
if (finalResult.IsSuccedded)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
changed = true
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
changed = false
|
||||
public async Task<IActionResult> OnPostCheckPhoneValid(string phone)
|
||||
{
|
||||
var result = _accountApplication.Search(new AccountSearchModel() { Mobile = phone }).FirstOrDefault();
|
||||
if (result == null)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = false,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
SendSms(phone);
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void SendSms(string phone)
|
||||
{
|
||||
|
||||
var result = _accountApplication.Search(new AccountSearchModel() { Mobile = phone }).FirstOrDefault();
|
||||
if (result != null)
|
||||
{
|
||||
_accountApplication.SetVerifyCode(phone, result.Id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult OnPostWithMobile(string code, string phone)
|
||||
{
|
||||
var verfiyResult = _accountApplication.GetByVerifyCode(code, phone);
|
||||
if (verfiyResult != null)
|
||||
{
|
||||
|
||||
var result = _accountApplication.LoginWithMobile(verfiyResult.Id);
|
||||
if (result.IsSuccedded && result.SendId == 1)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
url = "/Admin",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (result.IsSuccedded && result.SendId == 2)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
url = "/Client",
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = false,
|
||||
});
|
||||
|
||||
}
|
||||
public IActionResult OnPostVerify(string code, string phone)
|
||||
{
|
||||
var result = _accountApplication.GetByVerifyCode(code, phone);
|
||||
if (result != null)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
user = result.Username,
|
||||
verfyId = result.Id
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult OnPostChangePass(long id, string username, string newpass)
|
||||
{
|
||||
var result = _accountApplication.GetByUserNameAndId(id, username);
|
||||
if (result != null)
|
||||
{
|
||||
var command = new ChangePassword()
|
||||
{
|
||||
Id = id,
|
||||
Password = newpass,
|
||||
RePassword = newpass
|
||||
};
|
||||
var finalResult = _accountApplication.ChangePassword(command);
|
||||
if (finalResult.IsSuccedded)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
changed = true
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = true,
|
||||
changed = false
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = false,
|
||||
changed = false
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
exist = false,
|
||||
changed = false
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RecaptchaResponse
|
||||
{
|
||||
[JsonProperty("success")]
|
||||
public bool Success { get; set; }
|
||||
[JsonProperty("success")]
|
||||
public bool Success { get; set; }
|
||||
|
||||
[JsonProperty("challenge_ts")]
|
||||
public DateTimeOffset ChallengeTs { get; set; }
|
||||
[JsonProperty("challenge_ts")]
|
||||
public DateTimeOffset ChallengeTs { get; set; }
|
||||
|
||||
[JsonProperty("hostname")]
|
||||
public string HostName { get; set; }
|
||||
[JsonProperty("hostname")]
|
||||
public string HostName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="A fully featured employer website which can be used to build CRM, CMS, etc">
|
||||
<meta name="author" content="gozareshgir">
|
||||
|
||||
<link rel="shortcut icon" href="~/AssetsClient/images/favicon.ico">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user