API ContractingParty Controller Merged
This commit is contained in:
8
0_Framework/Application/Enums/ActivationStatus.cs
Normal file
8
0_Framework/Application/Enums/ActivationStatus.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace _0_Framework.Application.Enums;
|
||||||
|
|
||||||
|
public enum ActivationStatus
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Active = 1,
|
||||||
|
DeActive = 2
|
||||||
|
}
|
||||||
8
0_Framework/Application/Enums/Gender.cs
Normal file
8
0_Framework/Application/Enums/Gender.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace _0_Framework.Application.Enums;
|
||||||
|
|
||||||
|
public enum Gender
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Male,
|
||||||
|
Female
|
||||||
|
}
|
||||||
8
0_Framework/Application/Enums/LegalType.cs
Normal file
8
0_Framework/Application/Enums/LegalType.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace _0_Framework.Application.Enums;
|
||||||
|
|
||||||
|
public enum LegalType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Real = 1,
|
||||||
|
Legal = 2
|
||||||
|
}
|
||||||
7
0_Framework/Application/SelectListViewModel.cs
Normal file
7
0_Framework/Application/SelectListViewModel.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace _0_Framework.Application;
|
||||||
|
|
||||||
|
public class SelectListViewModel
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Text { get; set; }
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
using _0_Framework.Domain;
|
using _0_Framework.Domain;
|
||||||
using AccountManagement.Application.Contracts.Account;
|
using AccountManagement.Application.Contracts.Account;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Company.Domain.ContarctingPartyAgg;
|
namespace Company.Domain.ContarctingPartyAgg;
|
||||||
|
|
||||||
@@ -42,6 +43,34 @@ public interface IPersonalContractingPartyRepository :IRepository<long, Personal
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیست طرف حساب ها
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ICollection<ContractingPartyGetListViewModel>> GetList(ContractingPartyGetListSearchModel searchModel);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیست طرف حساب برای سلکت لیست سرچ
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<ContractingPartySelectListViewModel>> GetSelectList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیستی از شماره ملی یا شناسه ملی بر اساس حقیقی یا حقوقی بودن
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// غیرفعال کردن طرف حساب و زیرمجموعه های آن
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<OperationResult<string>> DeactivateWithSubordinates(long id);
|
||||||
|
|
||||||
|
void Remove(PersonalContractingParty entity);
|
||||||
|
Task<GetRealContractingPartyDetailsViewModel> GetRealDetails(long id);
|
||||||
|
Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using _0_Framework.Application.Enums;
|
||||||
|
|
||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
public class ContractingPartyGetListSearchModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// تعدادی که برای لیست بعدی آیتم باید رد کنه
|
||||||
|
/// </summary>
|
||||||
|
public int PageIndex { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام شرکت یا نام و نام خانوادگی طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public string FullNameOrCompanyName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شناسه ملی یا شماره ملی
|
||||||
|
/// </summary>
|
||||||
|
public string NationalIdOrNationalCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام معرف
|
||||||
|
/// </summary>
|
||||||
|
public string RepresentativeName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نوع طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public LegalType ContractingPartyType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// وضعیت طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public ActivationStatus ContractingPartyStatus { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using _0_Framework.Application.Enums;
|
||||||
|
|
||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
public record ContractingPartyGetListEmployerViewModel(long EmployerId, string EmployerName);
|
||||||
|
|
||||||
|
public class ContractingPartyGetListViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آیدی طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public int ArchiveCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شناسه ملی یا شماره ملی
|
||||||
|
/// </summary>
|
||||||
|
public string NationalIdOrNationalCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public string ContractingPartyName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیست کارفرما ها
|
||||||
|
/// </summary>
|
||||||
|
public ICollection<ContractingPartyGetListEmployerViewModel> Employers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تعداد بلاک
|
||||||
|
/// </summary>
|
||||||
|
public int BlockTimes { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آیا بلاک هست
|
||||||
|
/// </summary>
|
||||||
|
public bool IsBlock { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آیا دارای قرارداد مالی است
|
||||||
|
/// </summary>
|
||||||
|
public bool HasInstitutionContract { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نوع طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public LegalType ContractingPartyType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// وضعیت طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public ActivationStatus Status { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using _0_Framework.Application;
|
||||||
|
|
||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
public class ContractingPartySelectListViewModel: SelectListViewModel
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
public class CreateLegalContractingParty
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آیدی معرف
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public long RepresentativeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام شرکت
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string CompanyName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شناسه ملی
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string NationalId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public int ArchiveCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام مستعار
|
||||||
|
/// </summary>
|
||||||
|
public string SureName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره ثبت
|
||||||
|
/// </summary>
|
||||||
|
public string RegisterId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره تلفن
|
||||||
|
/// </summary>
|
||||||
|
public string PhoneNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره تلفن نماینده
|
||||||
|
/// </summary>
|
||||||
|
public string AgentPhone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// استان
|
||||||
|
/// </summary>
|
||||||
|
public string State { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شهر
|
||||||
|
/// </summary>
|
||||||
|
public string City { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// محله
|
||||||
|
/// </summary>
|
||||||
|
public string Zone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نشانی
|
||||||
|
/// </summary>
|
||||||
|
public string Address { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
public class CreateRealContractingParty
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// نام
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string FName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام خانوادگی
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string LName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آیدی معرف
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public long RepresentativeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد ملی
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string NationalCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره شناسنامه
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string IdNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public int ArchiveCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام مستعار
|
||||||
|
/// </summary>
|
||||||
|
public string SureName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره تلفن
|
||||||
|
/// </summary>
|
||||||
|
public string PhoneNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره تلفن نماینده
|
||||||
|
/// </summary>
|
||||||
|
public string AgentPhone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// استان
|
||||||
|
/// </summary>
|
||||||
|
public string State { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شهر
|
||||||
|
/// </summary>
|
||||||
|
public string City { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// محله
|
||||||
|
/// </summary>
|
||||||
|
public string Zone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نشانی
|
||||||
|
/// </summary>
|
||||||
|
public string Address { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ویرایش طرف حساب حقوقی
|
||||||
|
/// </summary>
|
||||||
|
public class EditLegalContractingParty:CreateLegalContractingParty
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آیدی طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ویرایش طرف حساب حقیقی
|
||||||
|
/// </summary>
|
||||||
|
public class EditRealContractingParty:CreateRealContractingParty
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آیدی طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره ملی یا شناسه ملی بر اساس حقیقی یا حقوقی بودن
|
||||||
|
/// </summary>
|
||||||
|
public class GetContractingPartyNationalCodeOrNationalIdViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// شماره ملی یا شناسه ملی
|
||||||
|
/// </summary>
|
||||||
|
public string NationalCodeOrNationalId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ویو مدل جزئیات طرف حساب حقوقی
|
||||||
|
/// </summary>
|
||||||
|
public class GetLegalContractingPartyDetailsViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آیدی طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام کامل شرکت(به همراه نام مستعار)ء
|
||||||
|
/// </summary>
|
||||||
|
public string CompanyFullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام شرکت (بدون نام مستعار)ء
|
||||||
|
/// </summary>
|
||||||
|
public string CompanyName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام مستعار
|
||||||
|
/// </summary>
|
||||||
|
public string SureName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره ثبت
|
||||||
|
/// </summary>
|
||||||
|
public string RegisterId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره ملی
|
||||||
|
/// </summary>
|
||||||
|
public string NationalId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره تماس
|
||||||
|
/// </summary>
|
||||||
|
public string PhoneNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره تماس نماینده
|
||||||
|
/// </summary>
|
||||||
|
public string AgentPhone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آدرس
|
||||||
|
/// </summary>
|
||||||
|
public string Address { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// معرف
|
||||||
|
/// </summary>
|
||||||
|
public string RepresentativeName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آیدی معرف
|
||||||
|
/// </summary>
|
||||||
|
public long RepresentativeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public int ArchiveCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// استان
|
||||||
|
/// </summary>
|
||||||
|
public string State { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شهر
|
||||||
|
/// </summary>
|
||||||
|
public string City { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// محله
|
||||||
|
/// </summary>
|
||||||
|
public string Zone { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
|
||||||
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ویو مدل جزئیات طرف حساب حقیقی
|
||||||
|
/// </summary>
|
||||||
|
public class GetRealContractingPartyDetailsViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آیدی طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام
|
||||||
|
/// </summary>
|
||||||
|
public string FName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام خانوادگی
|
||||||
|
/// </summary>
|
||||||
|
public string LName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام و نام خانوادگی
|
||||||
|
/// </summary>
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد ملی
|
||||||
|
/// </summary>
|
||||||
|
public string NationalCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره شناسنامه
|
||||||
|
/// </summary>
|
||||||
|
public string IdNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره تلفن
|
||||||
|
/// </summary>
|
||||||
|
public string PhoneNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره تلفن نماینده
|
||||||
|
/// </summary>
|
||||||
|
public string AgentPhone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آدرس
|
||||||
|
/// </summary>
|
||||||
|
public string Address { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام معرف
|
||||||
|
/// </summary>
|
||||||
|
public string RepresentativeName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آیدی معرف
|
||||||
|
/// </summary>
|
||||||
|
public long RepresentativeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام مستعار
|
||||||
|
/// </summary>
|
||||||
|
public string SureName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
public int ArchiveCode { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// استان
|
||||||
|
/// </summary>
|
||||||
|
public string State { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شهر
|
||||||
|
/// </summary>
|
||||||
|
public string City { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// محله
|
||||||
|
/// </summary>
|
||||||
|
public string Zone { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
@@ -54,4 +55,79 @@ public interface IPersonalContractingPartyApp
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Api
|
||||||
|
/// <summary>
|
||||||
|
/// لیست طرف حساب ها
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ICollection<ContractingPartyGetListViewModel>> GetList(ContractingPartyGetListSearchModel searchModel);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیست طرف حساب برای سلکت لیست سرچ
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<ContractingPartySelectListViewModel>> GetSelectList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ایجاد طرف حساب حقیقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<OperationResult> CreateReal(CreateRealContractingParty command);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ایجاد ظرف حساب حقوقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<OperationResult> CreateLegal(CreateLegalContractingParty command);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیستی از شماره ملی یا شناسه ملی بر اساس حقیقی یا حقوقی بودن
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId();
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// حذف طرف حساب. در صورتی که طرف حساب دارای قرارداد مالی یا دارای کارفرما باشد غیرفعال میشود
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<OperationResult<string>> Delete(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ویرایش طرف حساب حقیقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
OperationResult EditRealApi(EditRealContractingParty command);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ویرایش طرف حساب حقوقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
OperationResult EditLegal(EditLegalContractingParty command);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// گرفتن جزئیات طرف حساب حقوقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<GetRealContractingPartyDetailsViewModel> GetRealDetails(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// گرفتن جزئیات طرف حساب حقوقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -47,4 +47,6 @@ public class PersonalContractingPartyViewModel
|
|||||||
public bool IsAuthenticated { get; set; }
|
public bool IsAuthenticated { get; set; }
|
||||||
public List<EmployerViewModel> EmployerList { get; set; }
|
public List<EmployerViewModel> EmployerList { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
using Company.Domain.ContarctingPartyAgg;
|
using Company.Domain.ContarctingPartyAgg;
|
||||||
using Company.Domain.empolyerAgg;
|
using Company.Domain.empolyerAgg;
|
||||||
using CompanyManagment.App.Contracts.Representative;
|
using CompanyManagment.App.Contracts.Representative;
|
||||||
using Company.Domain.InstitutionContractAgg;
|
using Company.Domain.InstitutionContractAgg;
|
||||||
|
using CompanyManagment.EFCore.Repository;
|
||||||
|
|
||||||
namespace CompanyManagment.Application;
|
namespace CompanyManagment.Application;
|
||||||
|
|
||||||
public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
||||||
{
|
{
|
||||||
private readonly IPersonalContractingPartyRepository _personalContractingPartyRepository2;
|
private readonly IPersonalContractingPartyRepository _personalContractingPartyRepository;
|
||||||
private readonly IRepresentativeApplication _representativeApplication;
|
private readonly IRepresentativeApplication _representativeApplication;
|
||||||
private readonly IEmployerRepository _employerRepository;
|
private readonly IEmployerRepository _employerRepository;
|
||||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||||
@@ -26,7 +28,7 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
public PersonalContractingPartyApplication(
|
public PersonalContractingPartyApplication(
|
||||||
IPersonalContractingPartyRepository personalContractingPartyRepository, IRepresentativeApplication representativeApplication, IEmployerRepository employerRepository, IInstitutionContractRepository institutionContractRepository)
|
IPersonalContractingPartyRepository personalContractingPartyRepository, IRepresentativeApplication representativeApplication, IEmployerRepository employerRepository, IInstitutionContractRepository institutionContractRepository)
|
||||||
{
|
{
|
||||||
_personalContractingPartyRepository2 = personalContractingPartyRepository;
|
_personalContractingPartyRepository = personalContractingPartyRepository;
|
||||||
_representativeApplication = representativeApplication;
|
_representativeApplication = representativeApplication;
|
||||||
_employerRepository = employerRepository;
|
_employerRepository = employerRepository;
|
||||||
_institutionContractRepository = institutionContractRepository;
|
_institutionContractRepository = institutionContractRepository;
|
||||||
@@ -36,7 +38,7 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
public OperationResult Create(CreatePersonalContractingParty command)
|
public OperationResult Create(CreatePersonalContractingParty command)
|
||||||
{
|
{
|
||||||
var opration = new OperationResult();
|
var opration = new OperationResult();
|
||||||
if (_personalContractingPartyRepository2.Exists(x =>
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
x.LName == command.LName && x.Nationalcode == command.Nationalcode && x.SureName == command.SureName ))
|
x.LName == command.LName && x.Nationalcode == command.Nationalcode && x.SureName == command.SureName ))
|
||||||
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||||
if (command.RepresentativeId < 1)
|
if (command.RepresentativeId < 1)
|
||||||
@@ -54,14 +56,14 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
// return opration.Failed("نام خانوادگی وارد شده تکراری است");
|
// return opration.Failed("نام خانوادگی وارد شده تکراری است");
|
||||||
|
|
||||||
//}
|
//}
|
||||||
if (_personalContractingPartyRepository2.Exists(x => x.Nationalcode == command.Nationalcode && x.LName != command.LName))
|
if (_personalContractingPartyRepository.Exists(x => x.Nationalcode == command.Nationalcode && x.LName != command.LName))
|
||||||
{
|
{
|
||||||
nationalcodeIsOk = false;
|
nationalcodeIsOk = false;
|
||||||
|
|
||||||
return opration.Failed("کد ملی وارد شده تکراری است");
|
return opration.Failed("کد ملی وارد شده تکراری است");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_personalContractingPartyRepository2.Exists(x => x.ArchiveCode == command.ArchiveCode))
|
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode))
|
||||||
return opration.Failed("کد طرف حساب تکراری است");
|
return opration.Failed("کد طرف حساب تکراری است");
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -132,8 +134,8 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
command.State,command.City,command.Zone,command.SureName);
|
command.State,command.City,command.Zone,command.SureName);
|
||||||
|
|
||||||
|
|
||||||
_personalContractingPartyRepository2.Create(personalContractingParty);
|
_personalContractingPartyRepository.Create(personalContractingParty);
|
||||||
_personalContractingPartyRepository2.SaveChanges();
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
|
|
||||||
return opration.Succcedded();
|
return opration.Succcedded();
|
||||||
|
|
||||||
@@ -152,13 +154,13 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
public OperationResult Edit2(EditPersonalContractingParty command)
|
public OperationResult Edit2(EditPersonalContractingParty command)
|
||||||
{
|
{
|
||||||
var opration = new OperationResult();
|
var opration = new OperationResult();
|
||||||
var personalContractingParty = _personalContractingPartyRepository2.Get(command.Id);
|
var personalContractingParty = _personalContractingPartyRepository.Get(command.Id);
|
||||||
if (personalContractingParty == null)
|
if (personalContractingParty == null)
|
||||||
return opration.Failed("رکورد مورد نظر یافت نشد");
|
return opration.Failed("رکورد مورد نظر یافت نشد");
|
||||||
|
|
||||||
personalContractingParty.Edit2(command.Address);
|
personalContractingParty.Edit2(command.Address);
|
||||||
|
|
||||||
_personalContractingPartyRepository2.SaveChanges();
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
return opration.Succcedded();
|
return opration.Succcedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +168,7 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
{
|
{
|
||||||
|
|
||||||
var opration = new OperationResult();
|
var opration = new OperationResult();
|
||||||
if (_personalContractingPartyRepository2.Exists(x =>
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
x.LName == command.LName && x.RegisterId == command.RegisterId && x.SureName == command.SureName))
|
x.LName == command.LName && x.RegisterId == command.RegisterId && x.SureName == command.SureName))
|
||||||
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||||
if (command.RepresentativeId < 1)
|
if (command.RepresentativeId < 1)
|
||||||
@@ -174,23 +176,23 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (_personalContractingPartyRepository2.Exists(x => x.LName == command.LName && x.SureName == command.SureName))
|
if (_personalContractingPartyRepository.Exists(x => x.LName == command.LName && x.SureName == command.SureName))
|
||||||
{
|
{
|
||||||
legalNameIsOk = false;
|
legalNameIsOk = false;
|
||||||
return opration.Failed("نام شرکت وارد شده تکراری است");
|
return opration.Failed("نام شرکت وارد شده تکراری است");
|
||||||
}
|
}
|
||||||
if (_personalContractingPartyRepository2.Exists(x => x.RegisterId == command.RegisterId && x.LName != command.LName))
|
if (_personalContractingPartyRepository.Exists(x => x.RegisterId == command.RegisterId && x.LName != command.LName))
|
||||||
{
|
{
|
||||||
registerIdIsOk = false;
|
registerIdIsOk = false;
|
||||||
return opration.Failed("شماره ثبت وارد شده تکراری است");
|
return opration.Failed("شماره ثبت وارد شده تکراری است");
|
||||||
|
|
||||||
}
|
}
|
||||||
if (_personalContractingPartyRepository2.Exists(x => x.NationalId == command.NationalId && x.LName != command.LName))
|
if (_personalContractingPartyRepository.Exists(x => x.NationalId == command.NationalId && x.LName != command.LName))
|
||||||
{
|
{
|
||||||
nationalIdIsOk = false;
|
nationalIdIsOk = false;
|
||||||
return opration.Failed("شناسه ملی وارد شده تکراری است");
|
return opration.Failed("شناسه ملی وارد شده تکراری است");
|
||||||
}
|
}
|
||||||
if (_personalContractingPartyRepository2.Exists(x => x.ArchiveCode == command.ArchiveCode))
|
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode))
|
||||||
return opration.Failed("کد طرف حساب تکراری است");
|
return opration.Failed("کد طرف حساب تکراری است");
|
||||||
|
|
||||||
|
|
||||||
@@ -204,8 +206,8 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
command.State, command.City, command.Zone,command.SureName);
|
command.State, command.City, command.Zone,command.SureName);
|
||||||
|
|
||||||
|
|
||||||
_personalContractingPartyRepository2.Create(legalContractingParty);
|
_personalContractingPartyRepository.Create(legalContractingParty);
|
||||||
_personalContractingPartyRepository2.SaveChanges();
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
|
|
||||||
return opration.Succcedded();
|
return opration.Succcedded();
|
||||||
|
|
||||||
@@ -223,15 +225,15 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
{
|
{
|
||||||
|
|
||||||
var opration = new OperationResult();
|
var opration = new OperationResult();
|
||||||
var personalContractingParty = _personalContractingPartyRepository2.Get(command.Id);
|
var personalContractingParty = _personalContractingPartyRepository.Get(command.Id);
|
||||||
if (personalContractingParty == null)
|
if (personalContractingParty == null)
|
||||||
return opration.Failed("رکورد مورد نظر یافت نشد");
|
return opration.Failed("رکورد مورد نظر یافت نشد");
|
||||||
if (command.RepresentativeId < 1)
|
if (command.RepresentativeId < 1)
|
||||||
return opration.Failed("لطفا معرف را انتخاب کنید");
|
return opration.Failed("لطفا معرف را انتخاب کنید");
|
||||||
if (_personalContractingPartyRepository2.Exists(x =>
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
x.LName == command.LName && x.Nationalcode == command.Nationalcode && x.SureName == command.SureName && x.id != command.Id))
|
x.LName == command.LName && x.Nationalcode == command.Nationalcode && x.SureName == command.SureName && x.id != command.Id))
|
||||||
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||||
if (_personalContractingPartyRepository2.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
|
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
|
||||||
return opration.Failed("کد طرف حساب تکراری است");
|
return opration.Failed("کد طرف حساب تکراری است");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -300,7 +302,7 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
command.Phone, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName, command.ArchiveCode,
|
command.Phone, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName, command.ArchiveCode,
|
||||||
command.State, command.City, command.Zone,command.SureName);
|
command.State, command.City, command.Zone,command.SureName);
|
||||||
|
|
||||||
_personalContractingPartyRepository2.SaveChanges();
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
return opration.Succcedded();
|
return opration.Succcedded();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -314,16 +316,16 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
{
|
{
|
||||||
|
|
||||||
var opration = new OperationResult();
|
var opration = new OperationResult();
|
||||||
var legalContractingParty = _personalContractingPartyRepository2.Get(command.Id);
|
var legalContractingParty = _personalContractingPartyRepository.Get(command.Id);
|
||||||
if (legalContractingParty == null)
|
if (legalContractingParty == null)
|
||||||
return opration.Failed("رکورد مورد نظر یافت نشد");
|
return opration.Failed("رکورد مورد نظر یافت نشد");
|
||||||
|
|
||||||
if (_personalContractingPartyRepository2.Exists(x =>
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
x.LName== command.LName && x.RegisterId == command.RegisterId &&x.SureName == command.SureName &&x.id != command.Id))
|
x.LName== command.LName && x.RegisterId == command.RegisterId &&x.SureName == command.SureName &&x.id != command.Id))
|
||||||
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||||
if (command.RepresentativeId < 1)
|
if (command.RepresentativeId < 1)
|
||||||
return opration.Failed("لطفا معرف را انتخاب کنید");
|
return opration.Failed("لطفا معرف را انتخاب کنید");
|
||||||
if (_personalContractingPartyRepository2.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
|
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
|
||||||
return opration.Failed("کد طرف حساب تکراری است");
|
return opration.Failed("کد طرف حساب تکراری است");
|
||||||
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
|
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
|
||||||
legalContractingParty.EditLegal(command.LName, command.RegisterId,
|
legalContractingParty.EditLegal(command.LName, command.RegisterId,
|
||||||
@@ -331,54 +333,54 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
command.Phone, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName,command.ArchiveCode,
|
command.Phone, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName,command.ArchiveCode,
|
||||||
command.State, command.City, command.Zone, command.SureName);
|
command.State, command.City, command.Zone, command.SureName);
|
||||||
|
|
||||||
_personalContractingPartyRepository2.SaveChanges();
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
return opration.Succcedded();
|
return opration.Succcedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditPersonalContractingParty GetDetails(long id)
|
public EditPersonalContractingParty GetDetails(long id)
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.GetDetails(id);
|
return _personalContractingPartyRepository.GetDetails(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string IsBlockByEmployerId(long employerId)
|
public string IsBlockByEmployerId(long employerId)
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.IsBlockByEmployerId(employerId);
|
return _personalContractingPartyRepository.IsBlockByEmployerId(employerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditPersonalContractingParty GetDetailsToEdit(long id)
|
public EditPersonalContractingParty GetDetailsToEdit(long id)
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.GetDetailsToEdit(id);
|
return _personalContractingPartyRepository.GetDetailsToEdit(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFullName(long id)
|
public string GetFullName(long id)
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.GetFullName(id);
|
return _personalContractingPartyRepository.GetFullName(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PersonalContractingPartyViewModel> GetPersonalContractingParties()
|
public List<PersonalContractingPartyViewModel> GetPersonalContractingParties()
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.GetPersonalContractingParties();
|
return _personalContractingPartyRepository.GetPersonalContractingParties();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PersonalContractingPartyViewModel> Search(PersonalContractingPartySearchModel searchModel2)
|
public List<PersonalContractingPartyViewModel> Search(PersonalContractingPartySearchModel searchModel2)
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.Search(searchModel2);
|
return _personalContractingPartyRepository.Search(searchModel2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetLastArchiveCode()
|
public int GetLastArchiveCode()
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.GetLastArchiveCode();
|
return _personalContractingPartyRepository.GetLastArchiveCode();
|
||||||
}
|
}
|
||||||
#region Mahan
|
#region Mahan
|
||||||
public List<string> SearchByName(string name)
|
public List<string> SearchByName(string name)
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.SearchByName(name);
|
return _personalContractingPartyRepository.SearchByName(name);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
public ContractingPartyAndStatmentIdViewModel GetContractingpartyIdByAccountId(long accountId)
|
public ContractingPartyAndStatmentIdViewModel GetContractingpartyIdByAccountId(long accountId)
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.GetContractingpartyIdByAccountId(accountId);
|
return _personalContractingPartyRepository.GetContractingpartyIdByAccountId(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -386,15 +388,15 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
|
|
||||||
public List<PersonalContractingPartyViewModel> GetPersonalContractingPartiesForNationalcode(string searchText)
|
public List<PersonalContractingPartyViewModel> GetPersonalContractingPartiesForNationalcode(string searchText)
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.GetPersonalContractingPartiesForNationalcode(searchText);
|
return _personalContractingPartyRepository.GetPersonalContractingPartiesForNationalcode(searchText);
|
||||||
|
|
||||||
}
|
}
|
||||||
public List<PersonalContractingPartyViewModel> SearchForMain(PersonalContractingPartySearchModel searchModel2)
|
public List<PersonalContractingPartyViewModel> SearchForMain(PersonalContractingPartySearchModel searchModel2)
|
||||||
{
|
{
|
||||||
var result= _personalContractingPartyRepository2.SearchForMain(searchModel2);
|
var result= _personalContractingPartyRepository.SearchForMain(searchModel2);
|
||||||
foreach (var item in result)
|
foreach (var item in result)
|
||||||
{
|
{
|
||||||
item.HasInstitutionContract = _personalContractingPartyRepository2.GetHasContract(item.id);
|
item.HasInstitutionContract = _personalContractingPartyRepository.GetHasContract(item.id);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -411,12 +413,12 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
//اونهایی که کارفرما یا قرارداد غیر فعال دارند غیر فعال می شوند
|
//اونهایی که کارفرما یا قرارداد غیر فعال دارند غیر فعال می شوند
|
||||||
if (_employerRepository.Exists(x => x.ContractingPartyId == id)|| _institutionContractRepository.Exists(x => x.ContractingPartyId == id))
|
if (_employerRepository.Exists(x => x.ContractingPartyId == id)|| _institutionContractRepository.Exists(x => x.ContractingPartyId == id))
|
||||||
{
|
{
|
||||||
opration= _personalContractingPartyRepository2.DeActiveAll(id);
|
opration= _personalContractingPartyRepository.DeActiveAll(id);
|
||||||
return opration;
|
return opration;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
opration = _personalContractingPartyRepository2.DeletePersonalContractingParties(id);
|
opration = _personalContractingPartyRepository.DeletePersonalContractingParties(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return opration;
|
return opration;
|
||||||
@@ -428,10 +430,10 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
{
|
{
|
||||||
|
|
||||||
var opration = new OperationResult();
|
var opration = new OperationResult();
|
||||||
var contract = _personalContractingPartyRepository2.Get(id);
|
var contract = _personalContractingPartyRepository.Get(id);
|
||||||
if (contract == null)
|
if (contract == null)
|
||||||
return opration.Failed("رکورد مورد نظر یافت نشد");
|
return opration.Failed("رکورد مورد نظر یافت نشد");
|
||||||
return _personalContractingPartyRepository2.ActiveAll(id);
|
return _personalContractingPartyRepository.ActiveAll(id);
|
||||||
|
|
||||||
|
|
||||||
//var opration = new OperationResult();
|
//var opration = new OperationResult();
|
||||||
@@ -446,44 +448,44 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
public OperationResult DeActive(long id)
|
public OperationResult DeActive(long id)
|
||||||
{
|
{
|
||||||
var opration = new OperationResult();
|
var opration = new OperationResult();
|
||||||
var personalContracting = _personalContractingPartyRepository2.Get(id);
|
var personalContracting = _personalContractingPartyRepository.Get(id);
|
||||||
if (personalContracting == null)
|
if (personalContracting == null)
|
||||||
return opration.Failed("رکورد مورد نظر یافت نشد");
|
return opration.Failed("رکورد مورد نظر یافت نشد");
|
||||||
|
|
||||||
personalContracting.DeActive();
|
personalContracting.DeActive();
|
||||||
|
|
||||||
|
|
||||||
_personalContractingPartyRepository2.SaveChanges();
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
return opration.Succcedded();
|
return opration.Succcedded();
|
||||||
}
|
}
|
||||||
public bool GetHasContract(long id)
|
public bool GetHasContract(long id)
|
||||||
{
|
{
|
||||||
|
|
||||||
return _personalContractingPartyRepository2.GetHasContract(id);
|
return _personalContractingPartyRepository.GetHasContract(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Block(long id)
|
public OperationResult Block(long id)
|
||||||
{
|
{
|
||||||
var opration = new OperationResult();
|
var opration = new OperationResult();
|
||||||
var contract = _personalContractingPartyRepository2.Get(id);
|
var contract = _personalContractingPartyRepository.Get(id);
|
||||||
if (contract == null)
|
if (contract == null)
|
||||||
return opration.Failed("رکورد مورد نظر یافت نشد");
|
return opration.Failed("رکورد مورد نظر یافت نشد");
|
||||||
contract.Block();
|
contract.Block();
|
||||||
|
|
||||||
_personalContractingPartyRepository2.SaveChanges();
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
return opration.Succcedded();
|
return opration.Succcedded();
|
||||||
}
|
}
|
||||||
public OperationResult DisableBlock(long id)
|
public OperationResult DisableBlock(long id)
|
||||||
{
|
{
|
||||||
var opration = new OperationResult();
|
var opration = new OperationResult();
|
||||||
var personalContracting = _personalContractingPartyRepository2.Get(id);
|
var personalContracting = _personalContractingPartyRepository.Get(id);
|
||||||
if (personalContracting == null)
|
if (personalContracting == null)
|
||||||
return opration.Failed("رکورد مورد نظر یافت نشد");
|
return opration.Failed("رکورد مورد نظر یافت نشد");
|
||||||
|
|
||||||
int blockTimes = personalContracting.BlockTimes + 1;
|
int blockTimes = personalContracting.BlockTimes + 1;
|
||||||
personalContracting.DisableBlock(blockTimes);
|
personalContracting.DisableBlock(blockTimes);
|
||||||
_personalContractingPartyRepository2.SaveChanges();
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -499,7 +501,225 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
|
|||||||
|
|
||||||
public bool IsBlockCheckByWorkshopId(long workshopId)
|
public bool IsBlockCheckByWorkshopId(long workshopId)
|
||||||
{
|
{
|
||||||
return _personalContractingPartyRepository2.IsBlockCheckByWorkshopId(workshopId);
|
return _personalContractingPartyRepository.IsBlockCheckByWorkshopId(workshopId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Api
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<ICollection<ContractingPartyGetListViewModel>> GetList(
|
||||||
|
ContractingPartyGetListSearchModel searchModel)
|
||||||
|
{
|
||||||
|
return await _personalContractingPartyRepository.GetList(searchModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList()
|
||||||
|
{
|
||||||
|
return await _personalContractingPartyRepository.GetSelectList();
|
||||||
|
}
|
||||||
|
public async Task<OperationResult> CreateReal(CreateRealContractingParty command)
|
||||||
|
{
|
||||||
|
var operation = new OperationResult();
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
|
x.LName == command.LName && x.Nationalcode == command.NationalCode && x.SureName == command.SureName))
|
||||||
|
return operation.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||||
|
|
||||||
|
if (command.RepresentativeId < 1)
|
||||||
|
return operation.Failed("لطفا معرف را انتخاب کنید");
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x => x.Nationalcode == command.NationalCode && x.LName != command.LName))
|
||||||
|
{
|
||||||
|
nationalcodeIsOk = false;
|
||||||
|
|
||||||
|
return operation.Failed("کد ملی وارد شده تکراری است");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode))
|
||||||
|
return operation.Failed("کد طرف حساب تکراری است");
|
||||||
|
|
||||||
|
if (command.NationalCode.NationalCodeValid() != "valid")
|
||||||
|
{
|
||||||
|
return operation.Failed("کد ملی وارد شده نا معتبر است");
|
||||||
|
}
|
||||||
|
|
||||||
|
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
|
||||||
|
var personalContractingParty = new PersonalContractingParty(command.FName, command.LName,
|
||||||
|
command.NationalCode, command.IdNumber, "*", "*",
|
||||||
|
"حقیقی",
|
||||||
|
command.PhoneNumber, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName, command.ArchiveCode,
|
||||||
|
command.State, command.City, command.Zone, command.SureName);
|
||||||
|
|
||||||
|
|
||||||
|
await _personalContractingPartyRepository.CreateAsync(personalContractingParty);
|
||||||
|
await _personalContractingPartyRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
return operation.Succcedded();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> CreateLegal(CreateLegalContractingParty command)
|
||||||
|
{
|
||||||
|
var opration = new OperationResult();
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
|
x.LName == command.CompanyName && x.RegisterId == command.RegisterId && x.SureName == command.SureName))
|
||||||
|
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||||
|
|
||||||
|
if (command.RepresentativeId < 1)
|
||||||
|
return opration.Failed("لطفا معرف را انتخاب کنید");
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
|
x.LName == command.CompanyName && x.SureName == command.SureName))
|
||||||
|
{
|
||||||
|
legalNameIsOk = false;
|
||||||
|
return opration.Failed("نام شرکت وارد شده تکراری است");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
|
x.RegisterId == command.RegisterId && x.LName != command.CompanyName))
|
||||||
|
{
|
||||||
|
registerIdIsOk = false;
|
||||||
|
return opration.Failed("شماره ثبت وارد شده تکراری است");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
|
x.NationalId == command.NationalId && x.LName != command.CompanyName))
|
||||||
|
{
|
||||||
|
nationalIdIsOk = false;
|
||||||
|
return opration.Failed("شناسه ملی وارد شده تکراری است");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode))
|
||||||
|
return opration.Failed("کد طرف حساب تکراری است");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
|
||||||
|
var legalContractingParty = new PersonalContractingParty("*", command.CompanyName,
|
||||||
|
"*", "*", command.RegisterId, command.NationalId,
|
||||||
|
"حقوقی",
|
||||||
|
command.PhoneNumber, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName,
|
||||||
|
command.ArchiveCode,
|
||||||
|
command.State, command.City, command.Zone, command.SureName);
|
||||||
|
|
||||||
|
|
||||||
|
await _personalContractingPartyRepository.CreateAsync(legalContractingParty);
|
||||||
|
await _personalContractingPartyRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
return opration.Succcedded();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId()
|
||||||
|
{
|
||||||
|
return await _personalContractingPartyRepository.GetNationalCodeOrNationalId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult<string>> Delete(long id)
|
||||||
|
{
|
||||||
|
var operationResult = new OperationResult<string>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//اگر دارای قرارداد یا دازای کارفرما باشد غیر فعال می شود
|
||||||
|
if (_employerRepository.Exists(x => x.ContractingPartyId == id) || _institutionContractRepository.Exists(x => x.ContractingPartyId == id))
|
||||||
|
{
|
||||||
|
operationResult = await _personalContractingPartyRepository.DeactivateWithSubordinates(id);
|
||||||
|
return operationResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
var entity = _personalContractingPartyRepository.Get(id);
|
||||||
|
_personalContractingPartyRepository.Remove(entity);
|
||||||
|
operationResult.Succcedded("Deleted");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return operationResult.Failed("خطایی رخ داده است");
|
||||||
|
}
|
||||||
|
|
||||||
|
return operationResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationResult EditRealApi(EditRealContractingParty command)
|
||||||
|
{
|
||||||
|
var opration = new OperationResult();
|
||||||
|
var personalContractingParty = _personalContractingPartyRepository.Get(command.Id);
|
||||||
|
|
||||||
|
if (personalContractingParty == null)
|
||||||
|
return opration.Failed("رکورد مورد نظر یافت نشد");
|
||||||
|
|
||||||
|
if (command.RepresentativeId < 1)
|
||||||
|
return opration.Failed("لطفا معرف را انتخاب کنید");
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
|
x.LName == command.LName && x.Nationalcode == command.NationalCode && x.SureName == command.SureName && x.id != command.Id))
|
||||||
|
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
|
||||||
|
return opration.Failed("کد طرف حساب تکراری است");
|
||||||
|
|
||||||
|
if (command.NationalCode.NationalCodeValid() != "valid")
|
||||||
|
{
|
||||||
|
return opration.Failed("کد ملی وارد شده نا معتبر است");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
|
||||||
|
personalContractingParty.Edit(command.FName, command.LName,
|
||||||
|
command.NationalCode, command.IdNumber,
|
||||||
|
command.PhoneNumber, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName, command.ArchiveCode,
|
||||||
|
command.State, command.City, command.Zone, command.SureName);
|
||||||
|
|
||||||
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
|
return opration.Succcedded();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
return opration.Failed("خطایی رخ داده است");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationResult EditLegal(EditLegalContractingParty command)
|
||||||
|
{
|
||||||
|
var opration = new OperationResult();
|
||||||
|
var legalContractingParty = _personalContractingPartyRepository.Get(command.Id);
|
||||||
|
if (legalContractingParty == null)
|
||||||
|
return opration.Failed("رکورد مورد نظر یافت نشد");
|
||||||
|
|
||||||
|
if (_personalContractingPartyRepository.Exists(x =>
|
||||||
|
x.LName == command.CompanyName && x.RegisterId == command.RegisterId && x.SureName == command.SureName && x.id != command.Id))
|
||||||
|
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||||
|
if (command.RepresentativeId < 1)
|
||||||
|
return opration.Failed("لطفا معرف را انتخاب کنید");
|
||||||
|
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
|
||||||
|
return opration.Failed("کد طرف حساب تکراری است");
|
||||||
|
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
|
||||||
|
legalContractingParty.EditLegal(command.CompanyName, command.RegisterId,
|
||||||
|
command.NationalId,
|
||||||
|
command.PhoneNumber, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName, command.ArchiveCode,
|
||||||
|
command.State, command.City, command.Zone, command.SureName);
|
||||||
|
|
||||||
|
_personalContractingPartyRepository.SaveChanges();
|
||||||
|
return opration.Succcedded();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetRealContractingPartyDetailsViewModel> GetRealDetails(long id)
|
||||||
|
{
|
||||||
|
return await _personalContractingPartyRepository.GetRealDetails(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id)
|
||||||
|
{
|
||||||
|
return await _personalContractingPartyRepository.GetLegalDetails(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
|
using _0_Framework.Application.Enums;
|
||||||
|
using _0_Framework.Exceptions;
|
||||||
using _0_Framework.InfraStructure;
|
using _0_Framework.InfraStructure;
|
||||||
using AccountManagement.Application.Contracts.Account;
|
using AccountManagement.Application.Contracts.Account;
|
||||||
using AccountMangement.Infrastructure.EFCore;
|
using AccountMangement.Infrastructure.EFCore;
|
||||||
@@ -478,6 +481,248 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Api
|
||||||
|
public async Task<ICollection<ContractingPartyGetListViewModel>> GetList(ContractingPartyGetListSearchModel searchModel)
|
||||||
|
{
|
||||||
|
var personalContractingPartiesQuery = _context.PersonalContractingParties
|
||||||
|
.Include(x => x.Representative)
|
||||||
|
.Include(x => x.Employers).AsQueryable();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(searchModel.NationalIdOrNationalCode))
|
||||||
|
personalContractingPartiesQuery = personalContractingPartiesQuery
|
||||||
|
.Where(x => x.Nationalcode.Contains(searchModel.NationalIdOrNationalCode) ||
|
||||||
|
x.NationalId.Contains(searchModel.NationalIdOrNationalCode));
|
||||||
|
|
||||||
|
|
||||||
|
if (searchModel.ContractingPartyType != LegalType.None)
|
||||||
|
|
||||||
|
{
|
||||||
|
string type = searchModel.ContractingPartyType switch
|
||||||
|
{
|
||||||
|
LegalType.Legal => "حقوقی",
|
||||||
|
LegalType.Real => "حقیقی",
|
||||||
|
_ => ""
|
||||||
|
};
|
||||||
|
|
||||||
|
personalContractingPartiesQuery = personalContractingPartiesQuery
|
||||||
|
.Where(x => x.IsLegal == type);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (searchModel.ContractingPartyStatus != ActivationStatus.None)
|
||||||
|
{
|
||||||
|
string status = searchModel.ContractingPartyStatus switch
|
||||||
|
{
|
||||||
|
ActivationStatus.Active => "true",
|
||||||
|
ActivationStatus.DeActive => "false",
|
||||||
|
_ => ""
|
||||||
|
};
|
||||||
|
personalContractingPartiesQuery = personalContractingPartiesQuery
|
||||||
|
.Where(x => x.IsActiveString == status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(searchModel.RepresentativeName))
|
||||||
|
{
|
||||||
|
personalContractingPartiesQuery = personalContractingPartiesQuery
|
||||||
|
.Where(x => x.Representative.FullName.Contains(searchModel.RepresentativeName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(searchModel.FullNameOrCompanyName))
|
||||||
|
{
|
||||||
|
personalContractingPartiesQuery = personalContractingPartiesQuery.Where(x =>
|
||||||
|
(x.FName + " " + x.LName).Contains(searchModel.FullNameOrCompanyName));
|
||||||
|
}
|
||||||
|
var joinedQuery = personalContractingPartiesQuery
|
||||||
|
.GroupJoin(_context.InstitutionContractSet.Where(x => personalContractingPartiesQuery.Any(p => p.id == x.ContractingPartyId)),
|
||||||
|
contractingParty => contractingParty.id,
|
||||||
|
institution => institution.ContractingPartyId,
|
||||||
|
(contractingParty, institution) => new
|
||||||
|
{
|
||||||
|
contractingParty,
|
||||||
|
institution
|
||||||
|
});
|
||||||
|
|
||||||
|
var result = await joinedQuery.Skip(searchModel.PageIndex)
|
||||||
|
.Take(30).Select(x => new ContractingPartyGetListViewModel()
|
||||||
|
{
|
||||||
|
ArchiveCode = x.contractingParty.ArchiveCode,
|
||||||
|
BlockTimes = x.contractingParty.BlockTimes,
|
||||||
|
|
||||||
|
ContractingPartyName = x.contractingParty.IsLegal == "حقیقی" ?
|
||||||
|
x.contractingParty.SureName == null ? $"{x.contractingParty.FName} {x.contractingParty.LName}"
|
||||||
|
: $"{x.contractingParty.FName} {x.contractingParty.LName} {x.contractingParty.SureName}"
|
||||||
|
: x.contractingParty.SureName == null ? $"{x.contractingParty.LName}"
|
||||||
|
: $"{x.contractingParty.LName} {x.contractingParty.SureName}",
|
||||||
|
|
||||||
|
ContractingPartyType = x.contractingParty.IsLegal == "حقیقی" ? LegalType.Real : LegalType.Legal,
|
||||||
|
Employers = x.contractingParty.Employers.Take(11).Select(e => new ContractingPartyGetListEmployerViewModel(e.id, e.FullName)).ToList(),
|
||||||
|
Id = x.contractingParty.id,
|
||||||
|
IsBlock = x.contractingParty.IsBlock == "true",
|
||||||
|
HasInstitutionContract = x.institution.Any(i => i.IsActiveString == "true"),
|
||||||
|
NationalIdOrNationalCode = x.contractingParty.IsLegal == "حقیقی" ? x.contractingParty.Nationalcode : x.contractingParty.NationalId,
|
||||||
|
Status = x.contractingParty.IsActiveString == "true" ? ActivationStatus.Active : ActivationStatus.DeActive
|
||||||
|
}).ToListAsync();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList()
|
||||||
|
{
|
||||||
|
return await _context.PersonalContractingParties.Select(x => new ContractingPartySelectListViewModel
|
||||||
|
{
|
||||||
|
Id = x.id,
|
||||||
|
Text = x.IsLegal == "حقیقی" ? x.SureName == null
|
||||||
|
? $"{x.FName} {x.LName}"
|
||||||
|
: $"{x.FName} {x.LName} {x.SureName}"
|
||||||
|
: x.SureName == null ? $"{x.LName}"
|
||||||
|
: $"{x.LName} {x.SureName}",
|
||||||
|
|
||||||
|
}).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId()
|
||||||
|
{
|
||||||
|
return await _context.PersonalContractingParties.Select(x => new GetContractingPartyNationalCodeOrNationalIdViewModel
|
||||||
|
{
|
||||||
|
NationalCodeOrNationalId = x.IsLegal == "true" ? x.NationalId : x.Nationalcode
|
||||||
|
}).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult<string>> DeactivateWithSubordinates(long id)
|
||||||
|
{
|
||||||
|
var op = new OperationResult<string>();
|
||||||
|
;
|
||||||
|
using (var transaction = await _context.Database.BeginTransactionAsync())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var contractingParty = await _context.PersonalContractingParties
|
||||||
|
.Include(x => x.Employers)
|
||||||
|
.ThenInclude(x => x.Contracts)
|
||||||
|
.Include(x => x.Employers)
|
||||||
|
.ThenInclude(x => x.WorkshopEmployers)
|
||||||
|
.ThenInclude(x => x.Workshop)
|
||||||
|
.ThenInclude(x => x.Checkouts).FirstOrDefaultAsync(x => x.id == id);
|
||||||
|
if (contractingParty == null)
|
||||||
|
{
|
||||||
|
return op.Failed("چنین آیتمی وجود ندارد");
|
||||||
|
}
|
||||||
|
|
||||||
|
var employers = contractingParty.Employers;
|
||||||
|
|
||||||
|
var workshops = employers.SelectMany(x => x.WorkshopEmployers).Select(x => x.Workshop).ToList();
|
||||||
|
|
||||||
|
var contracts = employers.SelectMany(x => x.Contracts).ToList();
|
||||||
|
|
||||||
|
var checkouts = workshops.SelectMany(x => x.Checkouts).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
contractingParty.DeActive();
|
||||||
|
|
||||||
|
foreach (var employer in employers)
|
||||||
|
{
|
||||||
|
employer.DeActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var workshop in workshops)
|
||||||
|
{
|
||||||
|
workshop.DeActive(workshop.ArchiveCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var contract in contracts)
|
||||||
|
{
|
||||||
|
contract.DeActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var checkout in checkouts)
|
||||||
|
{
|
||||||
|
checkout.DeActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
await transaction.CommitAsync();
|
||||||
|
return op.Succcedded("DeActivate");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await transaction.RollbackAsync();
|
||||||
|
return op.Failed("غیرفعال کردن طرف حساب با خطا مواجه شد");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetRealContractingPartyDetailsViewModel> GetRealDetails(long id)
|
||||||
|
{
|
||||||
|
var res = await _context.PersonalContractingParties.Where(x => x.IsLegal == "حقیقی").Select(x =>
|
||||||
|
new GetRealContractingPartyDetailsViewModel()
|
||||||
|
{
|
||||||
|
Id = x.id,
|
||||||
|
IdNumber = x.IdNumber,
|
||||||
|
PhoneNumber = x.Phone,
|
||||||
|
AgentPhone = x.AgentPhone,
|
||||||
|
Address = x.Address,
|
||||||
|
FullName = x.SureName == null
|
||||||
|
? $"{x.FName} {x.LName}"
|
||||||
|
: $"{x.FName} {x.LName} {x.SureName}",
|
||||||
|
NationalCode = x.Nationalcode,
|
||||||
|
RepresentativeName = x.RepresentativeFullName,
|
||||||
|
ArchiveCode = x.ArchiveCode,
|
||||||
|
City = x.City,
|
||||||
|
FName = x.FName,
|
||||||
|
LName = x.LName,
|
||||||
|
SureName = x.SureName,
|
||||||
|
RepresentativeId = x.RepresentativeId,
|
||||||
|
State = x.State,
|
||||||
|
Zone = x.Zone
|
||||||
|
}).FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
||||||
|
if (res == null)
|
||||||
|
{
|
||||||
|
throw new BadRequestException("چنین طرف حسابی وجود ندارد");
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id)
|
||||||
|
{
|
||||||
|
var res = await _context.PersonalContractingParties.Where(x => x.IsLegal == "حقوقی").Select(x =>
|
||||||
|
new GetLegalContractingPartyDetailsViewModel()
|
||||||
|
{
|
||||||
|
Id = x.id,
|
||||||
|
PhoneNumber = x.Phone,
|
||||||
|
AgentPhone = x.AgentPhone,
|
||||||
|
Address = x.Address,
|
||||||
|
CompanyFullName = x.SureName == null
|
||||||
|
? $"{x.LName}"
|
||||||
|
: $"{x.LName} {x.SureName}",
|
||||||
|
NationalId = x.NationalId,
|
||||||
|
RegisterId = x.RegisterId,
|
||||||
|
RepresentativeName = x.RepresentativeFullName,
|
||||||
|
RepresentativeId = x.RepresentativeId,
|
||||||
|
State = x.State,
|
||||||
|
SureName = x.SureName,
|
||||||
|
Zone = x.Zone,
|
||||||
|
ArchiveCode = x.ArchiveCode,
|
||||||
|
City = x.City,
|
||||||
|
CompanyName = x.LName
|
||||||
|
}).FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
||||||
|
if (res == null)
|
||||||
|
{
|
||||||
|
throw new BadRequestException("چنین طرف حسابی وجود ندارد");
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using _0_Framework.Application;
|
||||||
|
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using ServiceHost.BaseControllers;
|
||||||
|
|
||||||
|
namespace ServiceHost.Areas.Admin.Controllers;
|
||||||
|
|
||||||
|
public class ContractingPartyController : AdminController
|
||||||
|
{
|
||||||
|
private readonly IPersonalContractingPartyApp _contractingPartyApplication;
|
||||||
|
|
||||||
|
public ContractingPartyController(IPersonalContractingPartyApp contractingPartyApplication)
|
||||||
|
{
|
||||||
|
_contractingPartyApplication = contractingPartyApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیست طرف حساب
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<ICollection<ContractingPartyGetListViewModel>>> Get([FromQuery] ContractingPartyGetListSearchModel searchModel)
|
||||||
|
{
|
||||||
|
var watch = new Stopwatch();
|
||||||
|
watch.Start();
|
||||||
|
var result = await _contractingPartyApplication.GetList(searchModel);
|
||||||
|
Console.WriteLine(watch.Elapsed);
|
||||||
|
return result.ToList();
|
||||||
|
}
|
||||||
|
[HttpGet("t/{name}")]
|
||||||
|
public async Task<List<string>> TestApi(string name)
|
||||||
|
{
|
||||||
|
var res = _contractingPartyApplication.SearchByName(name).Where(x=>x.Contains(name)).ToList();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// جزئیات طرف حساب حقیقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("real/{id}")]
|
||||||
|
public async Task<ActionResult<GetRealContractingPartyDetailsViewModel>> GetDetailsReal(long id)
|
||||||
|
{
|
||||||
|
var result = await _contractingPartyApplication.GetRealDetails(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// جزئیات طرف حساب حقوقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("legal/{id}")]
|
||||||
|
public async Task<ActionResult<GetLegalContractingPartyDetailsViewModel>> GetDetailsLegal(long id)
|
||||||
|
{
|
||||||
|
var result = await _contractingPartyApplication.GetLegalDetails(id);
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ایجاد طرف حساب حقیقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("real")]
|
||||||
|
public async Task<ActionResult<OperationResult>> CreateReal([FromBody] CreateRealContractingParty command)
|
||||||
|
{
|
||||||
|
var result = await _contractingPartyApplication.CreateReal(command);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ایجاد طرف حساب حقوقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("legal")]
|
||||||
|
public async Task<ActionResult<OperationResult>> CreateLegal([FromBody] CreateLegalContractingParty command)
|
||||||
|
{
|
||||||
|
var result = await _contractingPartyApplication.CreateLegal(command);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ویرایش طرف حساب حقیقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut("real")]
|
||||||
|
public ActionResult<OperationResult> EditReal([FromBody] EditRealContractingParty command)
|
||||||
|
{
|
||||||
|
var result = _contractingPartyApplication.EditRealApi(command);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ویرایش طرف حساب حقوقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut("legal")]
|
||||||
|
public ActionResult<OperationResult> EditLegal([FromBody] EditLegalContractingParty command)
|
||||||
|
{
|
||||||
|
var result = _contractingPartyApplication.EditLegal(command);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// چک کردن بلاک بودن طرف حساب با آیدی کارفرما
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="employerId">آیدی کارفرما</param>
|
||||||
|
/// <returns>true - false - NotFound</returns>
|
||||||
|
[HttpGet("is_block/{employerId}")]
|
||||||
|
public ActionResult<string> IsBlockByEmployerId(long employerId)
|
||||||
|
{
|
||||||
|
var result = _contractingPartyApplication.IsBlockByEmployerId(employerId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// گرفتن آخرین کد بایگانی کارگاه
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("last_archive_code")]
|
||||||
|
public ActionResult<int> GetLastArchiveCodeByContractingPartyId()
|
||||||
|
{
|
||||||
|
var data = _contractingPartyApplication.GetLastArchiveCode();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// سلکت لیست طرف حساب برای جستجو
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("selectList")]
|
||||||
|
public async Task<ActionResult<List<ContractingPartySelectListViewModel>>> GetSelectList()
|
||||||
|
{
|
||||||
|
return await _contractingPartyApplication.GetSelectList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیست شناسه ملی یا شماره ملی برای جستجوی
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("national_Code_Select_list")]
|
||||||
|
public async Task<ActionResult<List<GetContractingPartyNationalCodeOrNationalIdViewModel>>> GetNationalCodeOrNationalId()
|
||||||
|
{
|
||||||
|
return await _contractingPartyApplication.GetNationalCodeOrNationalId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// حذف طرف حساب. درصورت داشتن قرارداد مالی یا داشتن کارفرما، طرف حساب غیرفعال میشود
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete]
|
||||||
|
public async Task<OperationResult<string>> DeleteContractingParty(long id)
|
||||||
|
{
|
||||||
|
var operationResult = await _contractingPartyApplication.Delete(id);
|
||||||
|
|
||||||
|
return operationResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
12
ServiceHost/BaseControllers/AdminController.cs
Normal file
12
ServiceHost/BaseControllers/AdminController.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
namespace ServiceHost.BaseControllers;
|
||||||
|
|
||||||
|
//[Authorize(Policy = "AdminArea")]
|
||||||
|
[Area("Admin")]
|
||||||
|
[ApiExplorerSettings(GroupName = "Admin")]
|
||||||
|
[Route("api/[area]/[controller]")]
|
||||||
|
public class AdminController:ControllerBase
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -127,6 +127,12 @@ builder.Services.AddAuthorization(options =>
|
|||||||
|
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
builder.Services.AddControllers()
|
||||||
|
.AddJsonOptions(options =>
|
||||||
|
{
|
||||||
|
options.JsonSerializerOptions.Converters.Add(new System.Text.Json.Serialization.JsonStringEnumConverter());
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddRazorPages(options =>
|
builder.Services.AddRazorPages(options =>
|
||||||
options.Conventions.AuthorizeAreaFolder("Admin", "/", "AdminArea"));
|
options.Conventions.AuthorizeAreaFolder("Admin", "/", "AdminArea"));
|
||||||
|
|||||||
Reference in New Issue
Block a user