diff --git a/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs b/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs index 92463672..afee2160 100644 --- a/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs +++ b/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs @@ -1,17 +1,10 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Drawing; -using System.Linq; using System.Threading.Tasks; using _0_Framework.Application; using _0_Framework.Application.Sms; -using CompanyManagment.App.Contracts.Checkout; using CompanyManagment.App.Contracts.Law; using CompanyManagment.App.Contracts.TemporaryClientRegistration; -using CompanyManagment.App.Contracts.Workshop; -using CompanyManagment.App.Contracts.WorkshopPlan; -using Microsoft.AspNetCore.Mvc; namespace CompanyManagment.App.Contracts.InstitutionContract; @@ -80,11 +73,6 @@ public interface IInstitutionContractApplication [Obsolete("استفاده نشود، از متد غیرهمزمان استفاده شود")] - /// - /// چاپ یک قرارداد - /// - /// شناسه قرارداد - /// اطلاعات قرارداد برای چاپ InstitutionContractViewModel PrintOne(long id); /// @@ -164,6 +152,14 @@ public interface IInstitutionContractApplication #region Api + + /// + /// غیر فعال کردن قرارداد - اگر بدهی داشته باشد حالت آبی میشود. + /// + /// + /// + Task DeActiveAsync(long id); + /// /// لیست قرارداد های مالی /// diff --git a/CompanyManagment.Application/InstitutionContractApplication.cs b/CompanyManagment.Application/InstitutionContractApplication.cs index bafa7edf..85355e0a 100644 --- a/CompanyManagment.Application/InstitutionContractApplication.cs +++ b/CompanyManagment.Application/InstitutionContractApplication.cs @@ -917,6 +917,26 @@ public class InstitutionContractApplication : IInstitutionContractApplication return _institutionContractRepository.GetcontractAmount(countPerson); } + public async Task DeActiveAsync(long id) + { + var institutionContract = _institutionContractRepository.Get(id); + if (institutionContract == null) + { + throw new NotFoundException("رکورد مورد نظر یافت نشد"); + } + + var financialStatement =await _financialStatmentRepository.GetByContractingPartyId(id); + var balanceAmount =await _financialStatmentRepository.GetBalanceAmount(financialStatement.id); + if (balanceAmount.Amount>0) + { + institutionContract.DeActiveBlue(); + }else + { + institutionContract.DeActive(); + } + await _institutionContractRepository.SaveChangesAsync(); + } + public async Task> GetList( InstitutionContractListSearchModel searchModel) { diff --git a/CompanyManagment.Application/RollCallEmployeeApplication.cs b/CompanyManagment.Application/RollCallEmployeeApplication.cs index 9f4630cd..2179495c 100644 --- a/CompanyManagment.Application/RollCallEmployeeApplication.cs +++ b/CompanyManagment.Application/RollCallEmployeeApplication.cs @@ -166,11 +166,9 @@ public class RollCallEmployeeApplication : IRollCallEmployeeApplication return false; var now = DateTime.Now; return _rollCallEmployeeStatusRepository.Exists(x => x.RollCallEmployeeId == rollCallEmployee.Id && x.StartDate < now && x.EndDate > now); - - - + } - + public List GetEmployeeRollCalls(long workshopId) { return _rollCallEmployeeRepository.GetEmployeeRollCalls(workshopId); diff --git a/CompanyManagment.EFCore/Repository/FinancialStatmentRepository.cs b/CompanyManagment.EFCore/Repository/FinancialStatmentRepository.cs index 278bc861..b2a3ce6f 100644 --- a/CompanyManagment.EFCore/Repository/FinancialStatmentRepository.cs +++ b/CompanyManagment.EFCore/Repository/FinancialStatmentRepository.cs @@ -413,6 +413,7 @@ public class FinancialStatmentRepository : RepositoryBase GetByContractingPartyId(long contractingPartyId) { - return await _context.FinancialStatments.FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId); + return await _context.FinancialStatments + .FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId); } } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs b/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs index a1087f28..d131eb77 100644 --- a/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs +++ b/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs @@ -210,37 +210,24 @@ public class institutionContractController : AdminBaseController return new JsonResult(result); } - /// - /// حذف قرارداد مالی - /// - /// - /// - [HttpDelete("{id}")] - public async Task> Remove(long id) - { - _institutionContractApplication.RemoveContract(id); - return new OperationResult().Succcedded(); - - } + // /// + // /// حذف قرارداد مالی + // /// + // /// + // /// + // [HttpDelete("{id}")] + // public async Task> Remove(long id) + // { + // _institutionContractApplication.RemoveContract(id); + // return new OperationResult().Succcedded(); + // + // } [HttpPost("deActive/{id}")] - public ActionResult DeActive(long id, string balance) + public async Task DeActive(long id) { - var result = new OperationResult(); - if (balance == "0") - { - result = _institutionContractApplication.DeActive(id); - if (result.IsSuccedded) result = _institutionContractApplication.DeActiveAllConnections(id); - } - else - { - result = _institutionContractApplication.DeActiveBlue(id); - if (result.IsSuccedded) - result = _institutionContractApplication.DeActiveAllConnections(id); - } - - - return result; + await _institutionContractApplication.DeActiveAsync(id); + return Ok(); } ///