Compare commits
52 Commits
Feature/sa
...
Feature/pr
| Author | SHA1 | Date | |
|---|---|---|---|
| 23d42bd8f5 | |||
| 25aa76b16c | |||
| d6a9c5e87d | |||
|
|
34d336f43e | ||
|
|
6b81f383f6 | ||
|
|
54ff59de48 | ||
|
|
9f09b6af97 | ||
|
|
63e169b82d | ||
|
|
7339eaaadf | ||
|
|
e5c96c8bcb | ||
| 8622f12f12 | |||
| a20a847065 | |||
| 258a809451 | |||
|
|
6285c7320e | ||
|
|
17f117726e | ||
|
|
13fb6fec5d | ||
| 9bca1b81d6 | |||
| 9ff6b5cf56 | |||
|
|
04642b7257 | ||
| c1c9fe51cb | |||
|
|
0d2ac58bbb | ||
| 64693b2ca3 | |||
| 43ccb3a1dd | |||
| 0134111aba | |||
|
|
3cc7adae35 | ||
|
|
c97ea5356f | ||
| 03657b6848 | |||
| 69f4819bf6 | |||
|
|
1257e15b62 | ||
|
|
331fb24a99 | ||
| 3be1547137 | |||
| 15f1c938f7 | |||
| 7e563a0f01 | |||
| 900b4b3f4d | |||
| bdc6f95af8 | |||
| 7a73e69afa | |||
| a3fd3e6920 | |||
| 025c59e695 | |||
| 36ccd96352 | |||
| a7c97b22b4 | |||
| 4c143d6bbc | |||
| 0e5a0a16ac | |||
| 88f54b6310 | |||
| d4694e7e1c | |||
| 4bde4ade2d | |||
| bd12ff0506 | |||
|
|
21302803b6 | ||
| b7172630e2 | |||
| 0604514190 | |||
| ff5180eb75 | |||
| a1c9335487 | |||
| 20ece4886c |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -368,3 +368,6 @@ MigrationBackup/
|
||||
# Storage folder - ignore all uploaded files, thumbnails, and temporary files
|
||||
ServiceHost/Storage
|
||||
|
||||
.env
|
||||
.env.*
|
||||
|
||||
|
||||
@@ -31,8 +31,9 @@ public static class StaticWorkshopAccounts
|
||||
/// 381 - مهدی قربانی
|
||||
/// 392 - عمار حسن دوست
|
||||
/// 20 - سمیرا الهی نیا
|
||||
/// 322 - ماهان چمنی
|
||||
/// </summary>
|
||||
public static List<long> StaticAccountIds = [2, 3, 380, 381, 392, 20, 476];
|
||||
public static List<long> StaticAccountIds = [2, 3, 380, 381, 392, 20, 476,322];
|
||||
|
||||
/// <summary>
|
||||
/// این تاریخ در جدول اکانت لفت ورک به این معنیست
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<NuGetAudit>false</NuGetAudit>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Checkout : EntityBase
|
||||
string overNightWorkValue, string fridayWorkValue, string rotatingShifValue, string absenceValue,
|
||||
string totalDayOfLeaveCompute, string totalDayOfYearsCompute, string totalDayOfBunosesCompute,
|
||||
ICollection<CheckoutLoanInstallment> loanInstallments,
|
||||
ICollection<CheckoutSalaryAid> salaryAids, CheckoutRollCall checkoutRollCall, TimeSpan employeeMandatoryHours, bool hasInsuranceShareTheSameAsList)
|
||||
ICollection<CheckoutSalaryAid> salaryAids, CheckoutRollCall checkoutRollCall, TimeSpan employeeMandatoryHours, bool hasInsuranceShareTheSameAsList, ICollection<CheckoutReward> rewards,double rewardPay)
|
||||
{
|
||||
EmployeeFullName = employeeFullName;
|
||||
FathersName = fathersName;
|
||||
@@ -71,7 +71,7 @@ public class Checkout : EntityBase
|
||||
TotalClaims = totalClaims;
|
||||
TotalDeductions = totalDeductions;
|
||||
TotalPayment = totalPayment;
|
||||
RewardPay = 0;
|
||||
RewardPay = rewardPay;
|
||||
IsActiveString = "true";
|
||||
Signature = signature;
|
||||
MarriedAllowance = marriedAllowance;
|
||||
@@ -93,6 +93,7 @@ public class Checkout : EntityBase
|
||||
CheckoutRollCall = checkoutRollCall;
|
||||
EmployeeMandatoryHours = employeeMandatoryHours;
|
||||
HasInsuranceShareTheSameAsList = hasInsuranceShareTheSameAsList;
|
||||
Rewards = rewards;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +131,7 @@ public class Checkout : EntityBase
|
||||
public double BonusesPay { get; private set; }
|
||||
public double YearsPay { get; private set; }
|
||||
public double LeavePay { get; private set; }
|
||||
public double? RewardPay { get; private set; }
|
||||
public double RewardPay { get; private set; }
|
||||
public double InsuranceDeduction { get; private set; }
|
||||
public double TaxDeducation { get; private set; }
|
||||
public double InstallmentDeduction { get; private set; }
|
||||
@@ -223,6 +224,8 @@ public class Checkout : EntityBase
|
||||
|
||||
public ICollection<CheckoutLoanInstallment> LoanInstallments { get; set; } = [];
|
||||
public ICollection<CheckoutSalaryAid> SalaryAids { get; set; } = [];
|
||||
|
||||
public ICollection<CheckoutReward> Rewards { get; set; } = [];
|
||||
public CheckoutRollCall CheckoutRollCall { get; private set; }
|
||||
#endregion
|
||||
|
||||
@@ -239,7 +242,7 @@ public class Checkout : EntityBase
|
||||
double insuranceDeduction, double taxDeducation, double installmentDeduction,
|
||||
double salaryAidDeduction, double absenceDeduction, string sumOfWorkingDays
|
||||
, string archiveCode, string personnelCode,
|
||||
string totalClaims, string totalDeductions, double totalPayment, double? rewardPay)
|
||||
string totalClaims, string totalDeductions, double totalPayment, double rewardPay)
|
||||
{
|
||||
EmployeeFullName = employeeFullName;
|
||||
FathersName = fathersName;
|
||||
@@ -337,6 +340,11 @@ public class Checkout : EntityBase
|
||||
InstallmentDeduction = installmentsAmount;
|
||||
}
|
||||
|
||||
public void SetReward(ICollection<CheckoutReward> rewards, double rewardAmount)
|
||||
{
|
||||
RewardPay = rewardAmount;
|
||||
Rewards = rewards;
|
||||
}
|
||||
public void SetCheckoutRollCall(CheckoutRollCall checkoutRollCall)
|
||||
{
|
||||
CheckoutRollCall = checkoutRollCall;
|
||||
|
||||
57
Company.Domain/CheckoutAgg/ValueObjects/CheckoutReward.cs
Normal file
57
Company.Domain/CheckoutAgg/ValueObjects/CheckoutReward.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
|
||||
namespace Company.Domain.CheckoutAgg.ValueObjects;
|
||||
|
||||
public class CheckoutReward
|
||||
{
|
||||
public CheckoutReward(string amount, double amountDouble, string grantDateFa, DateTime grantDateGr, string description, string title, long entityId)
|
||||
{
|
||||
Amount = amount;
|
||||
AmountDouble = amountDouble;
|
||||
GrantDateFa = grantDateFa;
|
||||
GrantDateGr = grantDateGr;
|
||||
Description = description;
|
||||
Title = title;
|
||||
EntityId = entityId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پاداش
|
||||
/// string
|
||||
/// </summary>
|
||||
public string Amount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پاداش
|
||||
/// double
|
||||
/// </summary>
|
||||
public double AmountDouble { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ اعطاء
|
||||
/// شمسی
|
||||
/// </summary>
|
||||
public string GrantDateFa { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ اعطاء
|
||||
/// میلادی
|
||||
/// </summary>
|
||||
public DateTime GrantDateGr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// توضیحات
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// عنوان
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آی دی پاداش
|
||||
/// </summary>
|
||||
public long EntityId { get; set; }
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using CompanyManagment.App.Contracts.Leave;
|
||||
using CompanyManagment.App.Contracts.Loan;
|
||||
using CompanyManagment.App.Contracts.Reward;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using CompanyManagment.App.Contracts.SalaryAid;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.RollCallAgg;
|
||||
|
||||
@@ -53,6 +54,9 @@ public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
|
||||
List<SalaryAidViewModel> SalaryAidsForCheckout(long employeeId, long workshopId, DateTime checkoutStart,
|
||||
DateTime checkoutEnd);
|
||||
|
||||
List<RewardViewModel> RewardForCheckout(long employeeId, long workshopId, DateTime checkoutEnd,
|
||||
DateTime checkoutStart);
|
||||
|
||||
Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart,
|
||||
DateTime contractEnd, string shiftwork, bool hasRollCall, CreateWorkingHoursTemp command,bool holidayWorking);
|
||||
}
|
||||
@@ -15,12 +15,11 @@ public interface ISalaryAidRepository:IRepository<long,SalaryAid>
|
||||
void RemoveRange(IEnumerable<SalaryAid> salaryAids);
|
||||
|
||||
#region Pooya
|
||||
|
||||
/// <summary>
|
||||
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
|
||||
/// </summary>
|
||||
|
||||
SalaryAidsGroupedViewModel GetSearchListAsGrouped(SalaryAidSearchViewModel searchModel);
|
||||
SalaryAidsGroupedViewModel GetSearchListAsGrouped(SalaryAidSearchViewModel searchModel);
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -193,4 +193,9 @@ public class CreateCheckout
|
||||
/// پایه سنوات قبل از تاثیر ساعت کار
|
||||
/// </summary>
|
||||
public double BaseYearUnAffected { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا برای محاسبه پاداش مجاز است
|
||||
/// </summary>
|
||||
public bool RewardPayCompute { get; set; }
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
<NuGetAudit>false</NuGetAudit>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -324,6 +324,7 @@ public class InstitutionContractCreationWorkshopsResponse
|
||||
{
|
||||
public List<WorkshopTempViewModel> WorkshopTemps { get; set; }
|
||||
public string TotalAmount { get; set; }
|
||||
public Guid TempId { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractCreationWorkshopsRequest
|
||||
|
||||
@@ -151,6 +151,9 @@ public class CreateWorkshop
|
||||
/// تصفیه حساب بصورت استاتیک محاصبه شود
|
||||
/// </summary>
|
||||
public bool IsStaticCheckout { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آیا پاداش در فیش حقوقی محاسبه شود
|
||||
/// </summary>
|
||||
public bool RewardComputeOnCheckout { get; set; }
|
||||
}
|
||||
@@ -240,6 +240,16 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
|
||||
command.InstallmentDeduction = loanInstallments.Sum(x => x.AmountForMonth.MoneyToDouble());
|
||||
|
||||
var rewards = new List<CheckoutReward>();
|
||||
double rewardPay = 0;
|
||||
if (command.RewardPayCompute)
|
||||
{
|
||||
rewards = _rollCallMandatoryRepository.RewardForCheckout(command.EmployeeId, command.WorkshopId, checkoutEnd.ToGeorgianDateTime(), checkoutStart.ToGeorgianDateTime())
|
||||
.Select(x => new CheckoutReward(x.Amount, x.AmountDouble, x.GrantDateFa, x.GrantDateGr, x.Description, x.Title, x.Id)).ToList();
|
||||
|
||||
rewardPay = rewards.Sum(x => x.AmountDouble);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -361,7 +371,7 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
|
||||
|
||||
var totalClaimsDouble = monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + command.OvertimePay +
|
||||
command.NightworkPay + familyAllowance + bunos + years + command.LeavePay + command.FridayPay + command.ShiftPay;
|
||||
command.NightworkPay + familyAllowance + bunos + years + command.LeavePay + command.FridayPay + command.ShiftPay + rewardPay;
|
||||
var totalClaims = totalClaimsDouble.ToMoney();
|
||||
var totalDeductionDouble = insuranceDeduction + command.AbsenceDeduction + command.InstallmentDeduction + command.SalaryAidDeduction;
|
||||
var totalDeductions = totalDeductionDouble.ToMoney();
|
||||
@@ -386,7 +396,7 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
, command.OvertimePay, command.NightworkPay, command.FridayPay, 0, command.ShiftPay, familyAllowance, bunos, years, command.LeavePay, insuranceDeduction, 0, command.InstallmentDeduction, command.SalaryAidDeduction, command.AbsenceDeduction, sumOfWorkingDays,
|
||||
command.ArchiveCode, command.PersonnelCode, totalClaims, totalDeductions, totalPayment, command.Signature, marriedAllowance, command.LeaveCheckout, command.CreditLeaves, command.AbsencePeriod, command.AverageHoursPerDay, command.HasRollCall, command.OverTimeWorkValue, command.OverNightWorkValue
|
||||
, command.FridayWorkValue, command.RotatingShiftValue, command.AbsenceValue, command.TotalDayOfLeaveCompute, command.TotalDayOfYearsCompute, command.TotalDayOfBunosesCompute,
|
||||
loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList);
|
||||
loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList, rewards, rewardPay);
|
||||
|
||||
_checkoutRepository.CreateCkeckout(checkout).GetAwaiter().GetResult();
|
||||
//_checkoutRepository.SaveChanges();
|
||||
|
||||
@@ -1516,8 +1516,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
.Where(x => x.WorkshopCreated && x.WorkshopId is > 0).ToList();
|
||||
|
||||
var currentWorkshops = institutionContract.WorkshopGroup.CurrentWorkshops.ToList();
|
||||
var accountId = _contractingPartyRepository
|
||||
.GetAccountByPersonalContractingParty(institutionContract.ContractingPartyId).Id;
|
||||
var account = _contractingPartyRepository
|
||||
.GetAccountByPersonalContractingParty(institutionContract.ContractingPartyId);
|
||||
var accountId = account.Id;
|
||||
foreach (var createdWorkshop in initialCreatedWorkshops)
|
||||
{
|
||||
if (currentWorkshops.Any(x => x.WorkshopId == createdWorkshop.WorkshopId))
|
||||
@@ -1569,7 +1570,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
var previousInstitutionContract = await _institutionContractRepository
|
||||
.GetPreviousContract(institutionContract.id);
|
||||
previousInstitutionContract?.DeActive();
|
||||
ReActiveAllAfterCreateNew(institutionContract.ContractingPartyId);
|
||||
await _contractingPartyRepository.ActiveAllAsync(institutionContract.ContractingPartyId);
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
@@ -1524,7 +1524,8 @@ public class InsuranceListApplication : IInsuranceListApplication
|
||||
var dateOfBirth = employeeData.DateOfBirthGr.ToFarsi();
|
||||
var dateOfIssue = employeeData.DateOfIssueGr.ToFarsi();
|
||||
var leftDate = employeeData.LeftWorkDateGr != null ? employeeData.LeftWorkDateGr.Value.AddDays(-1) : new DateTime();
|
||||
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employeeData.StartWorkDateGr, leftDate, startDateGr, endDateGr, employeeData.EmployeeId);
|
||||
|
||||
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employeeData.StartWorkDateGr, leftDate, startDateGr, endDateGr, employeeData.EmployeeId);
|
||||
var leftWorkFa = workingDays.hasLeftWorkInMonth ? employeeData.LeftWorkDateGr.ToFarsi() : "";
|
||||
var startWorkFa = employeeData.StartWorkDateGr.ToFarsi();
|
||||
var workshop = _workShopRepository.GetDetails(workshopId);
|
||||
@@ -1606,7 +1607,7 @@ public class InsuranceListApplication : IInsuranceListApplication
|
||||
MaritalStatus = employeeData.MaritalStatus,
|
||||
|
||||
StartMonthCurrent = startMonthFa,
|
||||
WorkingDays = workingDays.countWorkingDays,
|
||||
WorkingDays = employeeData.WorkingDays,
|
||||
StartWorkDate = startWorkFa,
|
||||
StartWorkDateGr = employeeData.StartWorkDateGr,
|
||||
LeftWorkDate = leftWorkFa,
|
||||
|
||||
@@ -447,8 +447,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد");
|
||||
}
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -458,7 +457,10 @@ public class RollCallApplication : IRollCallApplication
|
||||
_rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId,
|
||||
x.StartDate!.Value,x.EndDate.Value);
|
||||
});
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date && x.ShiftDate.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
|
||||
if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date))
|
||||
{
|
||||
return operation.Failed("حضور غیاب در حال ویرایش را نمیتوانید از تاریخ شیفت عقب تر یا جلو تر ببرید");
|
||||
@@ -487,8 +489,8 @@ public class RollCallApplication : IRollCallApplication
|
||||
|
||||
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date
|
||||
&& x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date
|
||||
&& x.ShiftDate.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
|
||||
@@ -632,9 +634,6 @@ public class RollCallApplication : IRollCallApplication
|
||||
return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد");
|
||||
}
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
|
||||
newRollCallDates.ForEach(x =>
|
||||
{
|
||||
@@ -642,6 +641,11 @@ public class RollCallApplication : IRollCallApplication
|
||||
_rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId,
|
||||
x.StartDate!.Value,x.EndDate.Value);
|
||||
});
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date && x.ShiftDate.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
|
||||
if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date))
|
||||
{
|
||||
return operation.Failed("حضور غیاب در حال ویرایش را نمیتوانید از تاریخ شیفت عقب تر یا جلو تر ببرید");
|
||||
@@ -664,7 +668,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
&& (y.StartDate.Value.Date <= x.ContractEndGr.Date))))
|
||||
return operation.Failed("برای بازه های وارد شده فیش حقوقی ثبت شده است");
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date && x.ShiftDate.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
var currentDayRollCall = employeeRollCalls.FirstOrDefault(x => x.EndDate == null);
|
||||
|
||||
@@ -34,7 +34,7 @@ class CheckoutMapping : IEntityTypeConfiguration<Checkout>
|
||||
builder.Property(x => x.FamilyAllowance);
|
||||
builder.Property(x => x.HousingAllowance);
|
||||
builder.Property(x => x.ConsumableItems);
|
||||
builder.Property(x => x.RewardPay).HasColumnType("float").IsRequired(false);
|
||||
builder.Property(x => x.RewardPay);
|
||||
|
||||
builder.Property(x => x.LeaveCheckout);
|
||||
builder.Property(x => x.CreditLeaves);
|
||||
@@ -82,6 +82,15 @@ class CheckoutMapping : IEntityTypeConfiguration<Checkout>
|
||||
salaryAid.Property(x => x.CalculationDateTimeFa).HasMaxLength(15);
|
||||
});
|
||||
|
||||
|
||||
builder.OwnsMany(x => x.Rewards, reward =>
|
||||
{
|
||||
reward.Property(x => x.Description).HasColumnType("ntext");
|
||||
reward.Property(x => x.Title).HasMaxLength(255);
|
||||
reward.Property(x=> x.Amount).HasMaxLength(25);
|
||||
reward.Property(x => x.GrantDateFa).HasMaxLength(10);
|
||||
});
|
||||
|
||||
builder.OwnsOne(x => x.CheckoutRollCall, rollCall =>
|
||||
{
|
||||
rollCall.Property(x => x.TotalPresentTimeSpan).HasTimeSpanConversion();
|
||||
|
||||
11566
CompanyManagment.EFCore/Migrations/20260124132444_Add Reward to checkout.Designer.cs
generated
Normal file
11566
CompanyManagment.EFCore/Migrations/20260124132444_Add Reward to checkout.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddRewardtocheckout : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<double>(
|
||||
name: "RewardPay",
|
||||
table: "Checkouts",
|
||||
type: "float",
|
||||
nullable: false,
|
||||
defaultValue: 0.0,
|
||||
oldClrType: typeof(double),
|
||||
oldType: "float",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CheckoutReward",
|
||||
columns: table => new
|
||||
{
|
||||
Checkoutid = table.Column<long>(type: "bigint", nullable: false),
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Amount = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: true),
|
||||
AmountDouble = table.Column<double>(type: "float", nullable: false),
|
||||
GrantDateFa = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
|
||||
GrantDateGr = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Description = table.Column<string>(type: "ntext", nullable: true),
|
||||
Title = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
|
||||
EntityId = table.Column<long>(type: "bigint", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CheckoutReward", x => new { x.Checkoutid, x.Id });
|
||||
table.ForeignKey(
|
||||
name: "FK_CheckoutReward_Checkouts_Checkoutid",
|
||||
column: x => x.Checkoutid,
|
||||
principalTable: "Checkouts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CheckoutReward");
|
||||
|
||||
migrationBuilder.AlterColumn<double>(
|
||||
name: "RewardPay",
|
||||
table: "Checkouts",
|
||||
type: "float",
|
||||
nullable: true,
|
||||
oldClrType: typeof(double),
|
||||
oldType: "float");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -635,7 +635,7 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
b.Property<double?>("RewardPay")
|
||||
b.Property<double>("RewardPay")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("RotatingShiftValue")
|
||||
@@ -7501,6 +7501,49 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasForeignKey("Checkoutid");
|
||||
});
|
||||
|
||||
b.OwnsMany("Company.Domain.CheckoutAgg.ValueObjects.CheckoutReward", "Rewards", b1 =>
|
||||
{
|
||||
b1.Property<long>("Checkoutid")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property<int>("Id"));
|
||||
|
||||
b1.Property<string>("Amount")
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b1.Property<double>("AmountDouble")
|
||||
.HasColumnType("float");
|
||||
|
||||
b1.Property<string>("Description")
|
||||
.HasColumnType("ntext");
|
||||
|
||||
b1.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<string>("GrantDateFa")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
b1.Property<DateTime>("GrantDateGr")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b1.Property<string>("Title")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("nvarchar(255)");
|
||||
|
||||
b1.HasKey("Checkoutid", "Id");
|
||||
|
||||
b1.ToTable("CheckoutReward");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("Checkoutid");
|
||||
});
|
||||
|
||||
b.OwnsMany("Company.Domain.CheckoutAgg.ValueObjects.CheckoutSalaryAid", "SalaryAids", b1 =>
|
||||
{
|
||||
b1.Property<long>("Checkoutid")
|
||||
@@ -7545,6 +7588,8 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
|
||||
b.Navigation("LoanInstallments");
|
||||
|
||||
b.Navigation("Rewards");
|
||||
|
||||
b.Navigation("SalaryAids");
|
||||
|
||||
b.Navigation("Workshop");
|
||||
|
||||
@@ -531,6 +531,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
|
||||
entity.SetSalaryAid(command.SalaryAids, command.SalaryAidDeduction);
|
||||
entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction);
|
||||
entity.SetReward(command.Rewards,command.RewardPay);
|
||||
entity.SetCheckoutRollCall(command.CheckoutRollCall);
|
||||
entity.SetEmployeeMandatoryHours(command.EmployeeMandatoryHours);
|
||||
if(command.HasInsuranceShareTheSameAsList)
|
||||
@@ -934,7 +935,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
TotalClaims = item.TotalClaims,
|
||||
TotalDeductions = item.TotalDeductions,
|
||||
TotalPayment = item.TotalPayment.ToMoney(),
|
||||
RewardPay = item.RewardPay.ToMoneyNullable(),
|
||||
RewardPay = item.RewardPay.ToMoney(),
|
||||
ContractStartGr = item.ContractStart,
|
||||
ContractEndGr = item.ContractEnd,
|
||||
IsLeft = false,
|
||||
@@ -1335,7 +1336,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
TotalClaims = x.TotalClaims,
|
||||
TotalDeductions = x.TotalDeductions,
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoneyNullable(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
ContractStartGr = x.ContractStart,
|
||||
ContractEndGr = x.ContractEnd,
|
||||
IsLeft = false,
|
||||
|
||||
@@ -124,69 +124,69 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
public EditInstitutionContract GetDetails(long id)
|
||||
{
|
||||
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractDateFa = x.ContractDateFa,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
Description = x.Description,
|
||||
WorkshopManualCount = x.WorkshopManualCount,
|
||||
EmployeeManualCount = x.EmployeeManualCount,
|
||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||
ContractAmount = x.ContractAmount,
|
||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||
ObligationString = x.Obligation.ToMoney(),
|
||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||
ExtensionNo = x.ExtensionNo,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature,
|
||||
HasValueAddedTax = x.HasValueAddedTax,
|
||||
ValueAddedTax = x.ValueAddedTax,
|
||||
})
|
||||
{
|
||||
Id = x.id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractDateFa = x.ContractDateFa,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
Description = x.Description,
|
||||
WorkshopManualCount = x.WorkshopManualCount,
|
||||
EmployeeManualCount = x.EmployeeManualCount,
|
||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||
ContractAmount = x.ContractAmount,
|
||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||
ObligationString = x.Obligation.ToMoney(),
|
||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||
ExtensionNo = x.ExtensionNo,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature,
|
||||
HasValueAddedTax = x.HasValueAddedTax,
|
||||
ValueAddedTax = x.ValueAddedTax,
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
public EditInstitutionContract GetFirstContract(long contractingPartyId, string typeOfContract)
|
||||
{
|
||||
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractDateFa = x.ContractDateFa,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
Description = x.Description,
|
||||
WorkshopManualCount = x.WorkshopManualCount,
|
||||
EmployeeManualCount = x.EmployeeManualCount,
|
||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||
ObligationString = x.Obligation.ToMoney(),
|
||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||
ExtensionNo = x.ExtensionNo,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature
|
||||
})
|
||||
{
|
||||
Id = x.id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractDateFa = x.ContractDateFa,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
Description = x.Description,
|
||||
WorkshopManualCount = x.WorkshopManualCount,
|
||||
EmployeeManualCount = x.EmployeeManualCount,
|
||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||
ObligationString = x.Obligation.ToMoney(),
|
||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||
ExtensionNo = x.ExtensionNo,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature
|
||||
})
|
||||
.Where(x => x.ContractingPartyId == contractingPartyId && x.TypeOfContract == typeOfContract)
|
||||
.OrderBy(x => x.ExtensionNo).FirstOrDefault();
|
||||
}
|
||||
@@ -604,40 +604,40 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
}).ToList(),
|
||||
}).ToList();
|
||||
listQuery = listQuery.Select(x => new InstitutionContractViewModel()
|
||||
{
|
||||
Id = x.Id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractAmount = x.ContractAmount,
|
||||
TotalAmount = x.TotalAmount,
|
||||
SearchAmount = x.SearchAmount,
|
||||
IsActiveString = x.IsActiveString,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature,
|
||||
ExpireColor = x.ExpireColor,
|
||||
IsExpier = x.IsExpier,
|
||||
BalanceDouble = x.BalanceDouble,
|
||||
BalanceStr = x.BalanceStr,
|
||||
EmployerViewModels = x.EmployerViewModels,
|
||||
EmployerNo = x.EmployerNo,
|
||||
EmployerName = x.EmployerViewModels.Select(n => n.FullName).FirstOrDefault(),
|
||||
WorkshopViewModels = x.WorkshopViewModels,
|
||||
WorkshopCount = x.WorkshopCount,
|
||||
IsContractingPartyBlock = x.IsContractingPartyBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
EmployeeCount =
|
||||
{
|
||||
Id = x.Id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractAmount = x.ContractAmount,
|
||||
TotalAmount = x.TotalAmount,
|
||||
SearchAmount = x.SearchAmount,
|
||||
IsActiveString = x.IsActiveString,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature,
|
||||
ExpireColor = x.ExpireColor,
|
||||
IsExpier = x.IsExpier,
|
||||
BalanceDouble = x.BalanceDouble,
|
||||
BalanceStr = x.BalanceStr,
|
||||
EmployerViewModels = x.EmployerViewModels,
|
||||
EmployerNo = x.EmployerNo,
|
||||
EmployerName = x.EmployerViewModels.Select(n => n.FullName).FirstOrDefault(),
|
||||
WorkshopViewModels = x.WorkshopViewModels,
|
||||
WorkshopCount = x.WorkshopCount,
|
||||
IsContractingPartyBlock = x.IsContractingPartyBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
EmployeeCount =
|
||||
((x.WorkshopViewModels.Sum(w => w.LeftWorkIds.Count)) + (x.WorkshopViewModels.Sum(w =>
|
||||
w.InsuranceLeftWorkIds.Count(c => !w.LeftWorkIds.Contains(c))))).ToString(),
|
||||
ArchiveCode = x.WorkshopViewModels.Count > 0 ? ArchiveCodeFinder(x.WorkshopViewModels) : 0,
|
||||
}).OrderBy(x => x.WorkshopCount != "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
||||
ArchiveCode = x.WorkshopViewModels.Count > 0 ? ArchiveCodeFinder(x.WorkshopViewModels) : 0,
|
||||
}).OrderBy(x => x.WorkshopCount != "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
||||
.ThenBy(x => x.WorkshopCount == "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
||||
.ThenBy(x => x.IsExpier == "true")
|
||||
.ThenBy(x => x.ExpireColor == "purple")
|
||||
@@ -1474,7 +1474,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
IsInPersonContract = workshopGroup?.CurrentWorkshops
|
||||
.Any(y => y.Services.ContractInPerson) ?? true,
|
||||
IsOldContract = x.contract.SigningType == InstitutionContractSigningType.Legacy,
|
||||
InstitutionContractIsSentFlag = sendFlags.ContainsKey(x.contract.id) ? sendFlags[x.contract.id] : false
|
||||
InstitutionContractIsSentFlag =
|
||||
sendFlags.ContainsKey(x.contract.id) ? sendFlags[x.contract.id] : false
|
||||
};
|
||||
}).ToList()
|
||||
};
|
||||
@@ -2268,7 +2269,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
extenstionTemp
|
||||
);
|
||||
|
||||
var workshopIds = prevInstitutionContracts.WorkshopGroup.CurrentWorkshops.Select(x => x.WorkshopId.Value);
|
||||
var workshopIds = prevInstitutionContracts.WorkshopGroup?.CurrentWorkshops?.Select(x => x.WorkshopId.Value)??[];
|
||||
|
||||
var workshopsNotInInstitution = employerWorkshopIds.Where(x => !workshopIds.Contains(x)).ToList();
|
||||
|
||||
@@ -2276,7 +2277,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
.Where(x => workshopIds.Contains(x.id) || employerWorkshopIds.Contains(x.id))
|
||||
.ToListAsync();
|
||||
|
||||
var workshopDetails = prevInstitutionContracts.WorkshopGroup.CurrentWorkshops
|
||||
var workshopDetails = prevInstitutionContracts.WorkshopGroup?.CurrentWorkshops?
|
||||
.Select(x =>
|
||||
{
|
||||
var workshop = workshops.FirstOrDefault(w => w.id == x.WorkshopId);
|
||||
@@ -2316,7 +2317,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
WorkshopId = workshop?.id ?? 0,
|
||||
RollCallInPerson = service.RollCallInPerson
|
||||
};
|
||||
}).ToList();
|
||||
}).ToList()??[];
|
||||
var notIncludeWorskhopsLeftWork = await _context.LeftWorkList
|
||||
.Where(x => workshopsNotInInstitution.Contains(x.WorkshopId) && x.StartWorkDate <= DateTime.Now &&
|
||||
x.LeftWorkDate >= DateTime.Now)
|
||||
@@ -3358,9 +3359,17 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
OneMonthPrice = institution.ContractAmountWithTax.ToMoney(),
|
||||
OneMonthWithoutTax = institution.ContractAmount.ToMoney(),
|
||||
OneMonthTax = institution.ContractAmountTax.ToMoney(),
|
||||
VerifierFullName = institution.VerifierFullName,
|
||||
VerifierPhoneNumber = institution.VerifierPhoneNumber,
|
||||
VerifyCode = institution.VerifyCode,
|
||||
VerifierFullName =
|
||||
institution.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify
|
||||
? null
|
||||
: institution.VerifierFullName,
|
||||
VerifierPhoneNumber =
|
||||
institution.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify
|
||||
? null
|
||||
: institution.VerifierPhoneNumber,
|
||||
VerifyCode = institution.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify
|
||||
? null
|
||||
: institution.VerifyCode,
|
||||
VerifyDate = institution.VerifyCodeCreation.ToFarsi(),
|
||||
VerifyTime = institution.VerifyCodeCreation.ToString("HH:mm:ss"),
|
||||
Workshops = institution.WorkshopGroup.InitialWorkshops
|
||||
@@ -3563,10 +3572,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region PrivateMetods
|
||||
|
||||
/// <summary>
|
||||
@@ -3611,11 +3616,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//ایجاد سند مالی ماهانه
|
||||
|
||||
#region CreateMontlyTransaction
|
||||
|
||||
/// <summary>
|
||||
@@ -3625,7 +3627,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
public async Task CreateTransactionForInstitutionContracts(DateTime endOfMonthGr, string endOfMonthFa,
|
||||
string description)
|
||||
{
|
||||
|
||||
#region FindeNextMonth 1th
|
||||
|
||||
var firstDayOfMonthGr = ($"{endOfMonthFa.Substring(0, 8)}01").ToGeorgianDateTime();
|
||||
@@ -3656,7 +3657,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
SigningType = x.SigningType,
|
||||
InstallmentList = x.Installments
|
||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
||||
}).Where(x =>
|
||||
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0 &&
|
||||
@@ -3703,7 +3704,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
SigningType = x.SigningType,
|
||||
InstallmentList = x.Installments
|
||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
||||
}).ToListAsync();
|
||||
|
||||
@@ -4008,8 +4009,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<long> GetIdByInstallmentId(long installmentId)
|
||||
{
|
||||
return await _context.InstitutionContractSet.Include(x => x.Installments)
|
||||
@@ -4364,10 +4363,11 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var creationTemp = await _institutionContractCreationTemp.Find(x => x.Id == request.TempId)
|
||||
.FirstOrDefaultAsync();
|
||||
// creationTemp.SetContractingPartyInfo(request.LegalType,request.RealParty,request.LegalParty);
|
||||
|
||||
bool tempCreated = false;
|
||||
if (creationTemp == null)
|
||||
{
|
||||
throw new BadRequestException("دیتای درخواست شده نامعتبر است");
|
||||
creationTemp = new InstitutionContractCreationTemp();
|
||||
await _institutionContractCreationTemp.InsertOneAsync(creationTemp);
|
||||
}
|
||||
|
||||
List<WorkshopTempViewModel> workshopDetails = [];
|
||||
@@ -4445,7 +4445,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
Id = 0,
|
||||
IdNumberSerial = "",
|
||||
IdNumberSeri = "",
|
||||
|
||||
};
|
||||
creationTemp.SetContractingPartyInfo(request.LegalType, real, legal);
|
||||
}
|
||||
@@ -4462,7 +4461,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var res = new InstitutionContractCreationWorkshopsResponse()
|
||||
{
|
||||
TotalAmount = workshopDetails.Sum(x => x.WorkshopServicesAmount).ToMoney(),
|
||||
WorkshopTemps = workshopDetails
|
||||
WorkshopTemps = workshopDetails,
|
||||
TempId = creationTemp.Id
|
||||
};
|
||||
return res;
|
||||
}
|
||||
@@ -5221,11 +5221,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region CustomViewModels
|
||||
|
||||
public class WorkshopsAndEmployeeViewModel
|
||||
|
||||
@@ -245,7 +245,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
return new();
|
||||
}
|
||||
|
||||
return _accountContext.Accounts.Where(x => x.id == accId && x.IsActiveString == "true").Select(x =>
|
||||
return _accountContext.Accounts.Where(x => x.id == accId).Select(x =>
|
||||
new AccountViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
@@ -845,8 +845,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
public async Task<OperationResult> ActiveAllAsync(long id)
|
||||
{
|
||||
OperationResult result = new OperationResult();
|
||||
await using var transaction =await _context.Database.BeginTransactionAsync();
|
||||
await using var accountTransaction = await _accountContext.Database.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
{
|
||||
var personel = _context.PersonalContractingParties
|
||||
@@ -890,15 +889,12 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
await transaction.CommitAsync();
|
||||
await accountTransaction.CommitAsync();
|
||||
|
||||
result.Succcedded();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
result.Failed("فعال کردن طرف حساب با خطا مواجه شد");
|
||||
await transaction.RollbackAsync();
|
||||
await accountTransaction.RollbackAsync();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ReportClientRepository : IReportClientRepository
|
||||
TotalClaims = x.TotalClaims,
|
||||
TotalDeductions = x.TotalDeductions,
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoneyNullable(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
}).Where(x => x.WorkshopId == workshopId);
|
||||
|
||||
@@ -448,7 +448,7 @@ public class ReportClientRepository : IReportClientRepository
|
||||
TotalClaims = x.TotalClaims,
|
||||
TotalDeductions = x.TotalDeductions,
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoneyNullable(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
}).Where(x => x.WorkshopId == workshopId);
|
||||
|
||||
|
||||
@@ -5199,10 +5199,10 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
|
||||
};
|
||||
}
|
||||
|
||||
private List<RewardViewModel> RewardForCheckout(long employeeId, long workshopId, DateTime checkoutEnd,
|
||||
public List<RewardViewModel> RewardForCheckout(long employeeId, long workshopId, DateTime checkoutEnd,
|
||||
DateTime checkoutStart)
|
||||
{
|
||||
return _context.Rewards.Where(x =>
|
||||
var result = _context.Rewards.Where(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= checkoutEnd &&
|
||||
x.GrantDate >= checkoutStart).Select(x => new RewardViewModel
|
||||
{
|
||||
@@ -5215,6 +5215,8 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
|
||||
IsActive = x.IsActive,
|
||||
Id = x.id
|
||||
}).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<FineViewModel> FinesForCheckout(long employeeId, long workshopId, DateTime contractStart,
|
||||
|
||||
@@ -160,7 +160,9 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
||||
public EditWorkshop GetDetails(long id)
|
||||
{
|
||||
var emp = _context.WorkshopEmployers.Where(x => x.WorkshopId == id)
|
||||
.Select(x => x.EmployerId).ToList();
|
||||
.Select(x => x.Employer).ToList();
|
||||
var contractingPart = emp.Select(x => x.ContractingPartyId).ToList();
|
||||
bool rewardCompute = contractingPart.Any(x=>x == 30804);
|
||||
return _context.Workshops.Select(x => new EditWorkshop
|
||||
{
|
||||
Id = x.id,
|
||||
@@ -193,7 +195,7 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
||||
BonusesOptions = string.IsNullOrWhiteSpace(x.BonusesOptions) ? "EndOfContract1402leftWork1403" : x.BonusesOptions,
|
||||
YearsOptions = x.YearsOptions,
|
||||
IsOldContract = x.IsOldContract,
|
||||
EmployerIdList = emp,
|
||||
EmployerIdList = emp.Select(e=>e.id).ToList(),
|
||||
HasRollCallFreeVip = x.HasRollCallFreeVip,
|
||||
WorkshopHolidayWorking = x.WorkshopHolidayWorking,
|
||||
InsuranceCheckoutOvertime = x.InsuranceCheckoutOvertime,
|
||||
@@ -205,6 +207,7 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
||||
SignCheckout = x.SignCheckout,
|
||||
RotatingShiftCompute = x.RotatingShiftCompute,
|
||||
IsStaticCheckout = x.IsStaticCheckout,
|
||||
RewardComputeOnCheckout = rewardCompute
|
||||
|
||||
}).FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
5
Directory.Build.props
Normal file
5
Directory.Build.props
Normal file
@@ -0,0 +1,5 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<NuGetAudit>false</NuGetAudit>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,16 +0,0 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AddTaskToPhase;
|
||||
|
||||
/// <summary>
|
||||
/// Command to add a task to an existing phase
|
||||
/// </summary>
|
||||
public record AddTaskToPhaseCommand(
|
||||
Guid PhaseId,
|
||||
string Name,
|
||||
string? Description = null,
|
||||
ProjectTaskPriority Priority = ProjectTaskPriority.Medium,
|
||||
int OrderIndex = 0,
|
||||
DateTime? DueDate = null
|
||||
) : IBaseCommand;
|
||||
@@ -1,53 +0,0 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
using MediatR;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AddTaskToPhase;
|
||||
|
||||
public class AddTaskToPhaseCommandHandler : IRequestHandler<AddTaskToPhaseCommand, OperationResult>
|
||||
{
|
||||
private readonly IProjectPhaseRepository _phaseRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public AddTaskToPhaseCommandHandler(
|
||||
IProjectPhaseRepository phaseRepository,
|
||||
IUnitOfWork unitOfWork)
|
||||
{
|
||||
_phaseRepository = phaseRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(AddTaskToPhaseCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get phase
|
||||
var phase = await _phaseRepository.GetByIdAsync(request.PhaseId);
|
||||
if (phase == null)
|
||||
{
|
||||
return OperationResult.NotFound("فاز یافت نشد");
|
||||
}
|
||||
|
||||
// Add task
|
||||
var task = phase.AddTask(request.Name, request.Description);
|
||||
task.SetPriority(request.Priority);
|
||||
task.SetOrderIndex(request.OrderIndex);
|
||||
|
||||
if (request.DueDate.HasValue)
|
||||
{
|
||||
task.SetDates(dueDate: request.DueDate);
|
||||
}
|
||||
|
||||
// Save changes
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return OperationResult.Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return OperationResult.Failure($"خطا در افزودن تسک: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeDeployStatusProject;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
@@ -69,7 +71,7 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPr
|
||||
if (phase is null)
|
||||
return OperationResult.NotFound("فاز یافت نشد");
|
||||
|
||||
var tasks = phase.Tasks?.ToList() ?? new List<Domain.ProjectAgg.Entities.ProjectTask>();
|
||||
var tasks = phase.Tasks?.ToList() ?? new List<ProjectTask>();
|
||||
foreach (var t in tasks)
|
||||
{
|
||||
if (t.Priority != priority)
|
||||
@@ -89,10 +91,10 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPr
|
||||
if (project is null)
|
||||
return OperationResult.NotFound("پروژه یافت نشد");
|
||||
|
||||
var phases = project.Phases?.ToList() ?? new List<Domain.ProjectAgg.Entities.ProjectPhase>();
|
||||
var phases = project.Phases?.ToList() ?? new List<ProjectPhase>();
|
||||
foreach (var phase in phases)
|
||||
{
|
||||
var tasks = phase.Tasks?.ToList() ?? new List<Domain.ProjectAgg.Entities.ProjectTask>();
|
||||
var tasks = phase.Tasks?.ToList() ?? new List<ProjectTask>();
|
||||
foreach (var t in tasks)
|
||||
{
|
||||
if (t.Priority != priority)
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
||||
using GozareshgirProgramManager.Application.Services.FileManagement;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateBugSection;
|
||||
|
||||
public class CreateBugSectionCommandHandler : IBaseCommandHandler<CreateBugSectionCommand>
|
||||
{
|
||||
readonly IUnitOfWork _unitOfWork;
|
||||
readonly IBugSectionRepository _bugSectionRepository;
|
||||
readonly IFileUploadService _fileUploadService;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public CreateBugSectionCommandHandler(IUnitOfWork unitOfWork, IBugSectionRepository bugSectionRepository,
|
||||
IAuthHelper authHelper, IFileUploadService fileUploadService)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_bugSectionRepository = bugSectionRepository;
|
||||
|
||||
_authHelper = authHelper;
|
||||
_fileUploadService = fileUploadService;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(CreateBugSectionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var currentUserId = _authHelper.GetCurrentUserId()
|
||||
?? throw new UnAuthorizedException("کاربر احراز هویت نشده است");
|
||||
|
||||
#region Validation
|
||||
if (_bugSectionRepository.Exists(x => x.TaskId == request.TaskId))
|
||||
return OperationResult.Failure("برای این بخش قبلا تسک باگ ایجاد شده است");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(request.InitialDescription))
|
||||
return OperationResult.Failure("توضیحات باگ خالی است");
|
||||
|
||||
if (request.OriginalAssignedUserId == 0)
|
||||
return OperationResult.Failure("کاربر انتخاب نشده است");
|
||||
#endregion
|
||||
|
||||
var bug = new BugSection(request.TaskId, request.InitialDescription, request.OriginalAssignedUserId,
|
||||
request.Priority);
|
||||
await _bugSectionRepository.CreateAsync(bug);
|
||||
|
||||
if (request.Files.Any())
|
||||
{
|
||||
foreach (var file in request.Files)
|
||||
{
|
||||
var uploadedFile = await _fileUploadService.UploadFileAsync
|
||||
(
|
||||
file,
|
||||
FileCategory.BugSection,
|
||||
currentUserId
|
||||
);
|
||||
if (!uploadedFile.IsSuccess)
|
||||
{
|
||||
return OperationResult.Failure(uploadedFile.ErrorMessage ?? "خطا در آپلود فایل");
|
||||
}
|
||||
bug.AddDocument(new BugDocument(uploadedFile.FileId!.Value));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return OperationResult.Success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public record CreateBugSectionCommand(Guid TaskId, string InitialDescription, long OriginalAssignedUserId, ProjectTaskPriority Priority, List<IFormFile> Files) : IBaseCommand;
|
||||
|
||||
@@ -4,4 +4,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject;
|
||||
|
||||
public record CreateProjectCommand(string Name,ProjectHierarchyLevel Level,
|
||||
ProjectTaskPriority? Priority,
|
||||
Guid? ParentId):IBaseCommand;
|
||||
@@ -3,6 +3,9 @@ using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
@@ -16,7 +19,8 @@ public class CreateProjectCommandHandler : IBaseCommandHandler<CreateProjectComm
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
|
||||
public CreateProjectCommandHandler(IProjectRepository projectRepository, IUnitOfWork unitOfWork, IProjectTaskRepository projectTaskRepository, IProjectPhaseRepository projectPhaseRepository)
|
||||
public CreateProjectCommandHandler(IProjectRepository projectRepository, IUnitOfWork unitOfWork,
|
||||
IProjectTaskRepository projectTaskRepository, IProjectPhaseRepository projectPhaseRepository)
|
||||
{
|
||||
_projectRepository = projectRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
@@ -55,8 +59,8 @@ public class CreateProjectCommandHandler : IBaseCommandHandler<CreateProjectComm
|
||||
{
|
||||
if (!request.ParentId.HasValue)
|
||||
throw new BadRequestException("برای ایجاد فاز، شناسه پروژه الزامی است");
|
||||
|
||||
if(!_projectRepository.Exists(x=>x.Id == request.ParentId.Value))
|
||||
|
||||
if (!_projectRepository.Exists(x => x.Id == request.ParentId.Value))
|
||||
{
|
||||
throw new BadRequestException("والد پروژه یافت نشد");
|
||||
}
|
||||
@@ -69,14 +73,15 @@ public class CreateProjectCommandHandler : IBaseCommandHandler<CreateProjectComm
|
||||
{
|
||||
if (!request.ParentId.HasValue)
|
||||
throw new BadRequestException("برای ایجاد تسک، شناسه فاز الزامی است");
|
||||
|
||||
if(!_projectPhaseRepository.Exists(x=>x.Id == request.ParentId.Value))
|
||||
|
||||
if (!_projectPhaseRepository.Exists(x => x.Id == request.ParentId.Value))
|
||||
{
|
||||
throw new BadRequestException("والد پروژه یافت نشد");
|
||||
}
|
||||
|
||||
var projectTask = new ProjectTask(request.Name, request.ParentId.Value);
|
||||
var priority = request.Priority ?? ProjectTaskPriority.Low;
|
||||
|
||||
var projectTask = new ProjectTask(request.Name, request.ParentId.Value, priority);
|
||||
await _projectTaskRepository.CreateAsync(projectTask);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
using MediatR;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject;
|
||||
@@ -15,4 +17,5 @@ public class SetTimeSectionTime
|
||||
public string Description { get; set; }
|
||||
public int Hours { get; set; }
|
||||
public int Minutes { get; set; }
|
||||
public TaskSectionAdditionalTimeType Type { get; set; }
|
||||
}
|
||||
@@ -4,6 +4,9 @@ using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
||||
@@ -369,7 +372,7 @@ public class SetTimeProjectCommandHandler : IBaseCommandHandler<SetTimeProjectCo
|
||||
foreach (var additionalTime in sectionItem.AdditionalTime)
|
||||
{
|
||||
var additionalTimeSpan = TimeSpan.FromHours(additionalTime.Hours).Add(TimeSpan.FromMinutes(additionalTime.Minutes));
|
||||
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
|
||||
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Type, additionalTime.Description, addedByUserId);
|
||||
hasAdditionalTime = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Extensions;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetBugModalDetails;
|
||||
|
||||
public class GetBugModalDetailsQueryHandler : IBaseQueryHandler<GetBugModalDetailsQuery, GetBugModalDetailsResponse>
|
||||
{
|
||||
private readonly IProgramManagerDbContext _context;
|
||||
|
||||
public GetBugModalDetailsQueryHandler(IProgramManagerDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<GetBugModalDetailsResponse>> Handle(GetBugModalDetailsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var projectTask =await _context.ProjectTasks.Include(ph=>ph.Phase).ThenInclude(p=>p.Project).FirstOrDefaultAsync(x=>x.Id == request.TaskId);
|
||||
if(projectTask == null)
|
||||
return OperationResult<GetBugModalDetailsResponse>.NotFound("بخش یافت نشد");
|
||||
|
||||
var response = new GetBugModalDetailsResponse(projectTask.Name,projectTask.Phase.Name, projectTask.Phase.Project.Name);
|
||||
return OperationResult<GetBugModalDetailsResponse>.Success(response);
|
||||
}
|
||||
}
|
||||
|
||||
public record GetBugModalDetailsQuery(Guid TaskId) : IBaseQuery<GetBugModalDetailsResponse>;
|
||||
|
||||
public record GetBugModalDetailsResponse(string TaskName, string PhaseName, string ProjectName);
|
||||
@@ -10,8 +10,10 @@ public class GetProjectItemDto
|
||||
public int Percentage { get; init; }
|
||||
public ProjectHierarchyLevel Level { get; init; }
|
||||
public Guid? ParentId { get; init; }
|
||||
public int TotalHours { get; set; }
|
||||
public int Minutes { get; set; }
|
||||
|
||||
public TimeSpan TotalTime { get; init; }
|
||||
|
||||
public TimeSpan RemainingTime { get; init; }
|
||||
public AssignmentStatus Front { get; set; }
|
||||
public AssignmentStatus Backend { get; set; }
|
||||
public AssignmentStatus Design { get; set; }
|
||||
|
||||
@@ -4,6 +4,10 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
||||
|
||||
@@ -16,7 +20,8 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<GetProjectsListResponse>> Handle(GetProjectsListQuery request, CancellationToken cancellationToken)
|
||||
public async Task<OperationResult<GetProjectsListResponse>> Handle(GetProjectsListQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var projects = new List<GetProjectDto>();
|
||||
var phases = new List<GetPhaseDto>();
|
||||
@@ -51,13 +56,14 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
{
|
||||
return new List<GetProjectDto>();
|
||||
}
|
||||
|
||||
var entities = await query
|
||||
.OrderByDescending(p => p.CreationDate)
|
||||
.ToListAsync(cancellationToken);
|
||||
var result = new List<GetProjectDto>();
|
||||
foreach (var project in entities)
|
||||
{
|
||||
var (percentage, totalTime) = await CalculateProjectPercentage(project, cancellationToken);
|
||||
var (percentage, totalTime,remainingTime) = await CalculateProjectPercentage(project, cancellationToken);
|
||||
result.Add(new GetProjectDto
|
||||
{
|
||||
Id = project.Id,
|
||||
@@ -65,10 +71,12 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
Level = ProjectHierarchyLevel.Project,
|
||||
ParentId = null,
|
||||
Percentage = percentage,
|
||||
TotalHours = (int)totalTime.TotalHours,
|
||||
Minutes = totalTime.Minutes,
|
||||
TotalTime = totalTime,
|
||||
RemainingTime = remainingTime
|
||||
});
|
||||
}
|
||||
|
||||
result = result.OrderByDescending(x => x.Percentage).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -79,13 +87,14 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
{
|
||||
query = query.Where(x => x.ProjectId == parentId);
|
||||
}
|
||||
|
||||
var entities = await query
|
||||
.OrderByDescending(p => p.CreationDate)
|
||||
.ToListAsync(cancellationToken);
|
||||
var result = new List<GetPhaseDto>();
|
||||
foreach (var phase in entities)
|
||||
{
|
||||
var (percentage, totalTime) = await CalculatePhasePercentage(phase, cancellationToken);
|
||||
var (percentage, totalTime,remainingTime) = await CalculatePhasePercentage(phase, cancellationToken);
|
||||
result.Add(new GetPhaseDto
|
||||
{
|
||||
Id = phase.Id,
|
||||
@@ -93,10 +102,12 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
Level = ProjectHierarchyLevel.Phase,
|
||||
ParentId = phase.ProjectId,
|
||||
Percentage = percentage,
|
||||
TotalHours = (int)totalTime.TotalHours,
|
||||
Minutes = totalTime.Minutes,
|
||||
TotalTime = totalTime,
|
||||
RemainingTime = remainingTime
|
||||
});
|
||||
}
|
||||
result = result.OrderByDescending(x => x.Percentage).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -107,6 +118,7 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
{
|
||||
query = query.Where(x => x.PhaseId == parentId);
|
||||
}
|
||||
|
||||
var entities = await query
|
||||
.OrderByDescending(t => t.CreationDate)
|
||||
.ToListAsync(cancellationToken);
|
||||
@@ -118,7 +130,7 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
|
||||
foreach (var task in entities)
|
||||
{
|
||||
var (percentage, totalTime) = await CalculateTaskPercentage(task, cancellationToken);
|
||||
var (percentage, totalTime,remainingTime) = await CalculateTaskPercentage(task, cancellationToken);
|
||||
var sections = await _context.TaskSections
|
||||
.Include(s => s.Activities)
|
||||
.Include(s => s.Skill)
|
||||
@@ -140,13 +152,12 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
|
||||
// محاسبه SpentTime و RemainingTime
|
||||
var spentTime = TimeSpan.FromTicks(sections.Sum(s => s.Activities.Sum(a => a.GetTimeSpent().Ticks)));
|
||||
var remainingTime = totalTime - spentTime;
|
||||
|
||||
// ساخت section DTOs برای تمام Skills
|
||||
var sectionDtos = allSkills.Select(skill =>
|
||||
{
|
||||
var section = sections.FirstOrDefault(s => s.SkillId == skill.Id);
|
||||
|
||||
|
||||
if (section == null)
|
||||
{
|
||||
// اگر section وجود نداشت، یک DTO با وضعیت Unassigned برمیگردانیم
|
||||
@@ -184,18 +195,20 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
Level = ProjectHierarchyLevel.Task,
|
||||
ParentId = task.PhaseId,
|
||||
Percentage = percentage,
|
||||
TotalHours = (int)totalTime.TotalHours,
|
||||
Minutes = totalTime.Minutes,
|
||||
TotalTime = totalTime,
|
||||
SpentTime = spentTime,
|
||||
RemainingTime = remainingTime,
|
||||
Sections = sectionDtos,
|
||||
Priority = task.Priority
|
||||
});
|
||||
}
|
||||
result = result.OrderByDescending(x => x.Percentage).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task SetSkillFlags<TItem>(List<TItem> items, CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
||||
private async Task SetSkillFlags<TItem>(List<TItem> items, CancellationToken cancellationToken)
|
||||
where TItem : GetProjectItemDto
|
||||
{
|
||||
if (!items.Any())
|
||||
return;
|
||||
@@ -213,7 +226,8 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
}
|
||||
|
||||
|
||||
private async Task SetSkillFlagsForProjects<TItem>(List<TItem> items, List<Guid> projectIds, CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
||||
private async Task SetSkillFlagsForProjects<TItem>(List<TItem> items, List<Guid> projectIds,
|
||||
CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
||||
{
|
||||
// For projects: gather all phases, then tasks, then sections
|
||||
var phases = await _context.ProjectPhases
|
||||
@@ -243,7 +257,8 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SetSkillFlagsForPhases<TItem>(List<TItem> items, List<Guid> phaseIds, CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
||||
private async Task SetSkillFlagsForPhases<TItem>(List<TItem> items, List<Guid> phaseIds,
|
||||
CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
||||
{
|
||||
// For phases: gather tasks, then sections
|
||||
var tasks = await _context.ProjectTasks
|
||||
@@ -269,68 +284,81 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<(int Percentage, TimeSpan TotalTime)> CalculateProjectPercentage(Project project, CancellationToken cancellationToken)
|
||||
private async Task<(int Percentage, TimeSpan TotalTime,TimeSpan RemainingTime)> CalculateProjectPercentage(Project project,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var phases = await _context.ProjectPhases
|
||||
.Where(ph => ph.ProjectId == project.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
if (!phases.Any())
|
||||
return (0, TimeSpan.Zero);
|
||||
return (0, TimeSpan.Zero,TimeSpan.Zero);
|
||||
var phasePercentages = new List<int>();
|
||||
var totalTime = TimeSpan.Zero;
|
||||
var remainingTime = TimeSpan.Zero;
|
||||
foreach (var phase in phases)
|
||||
{
|
||||
var (phasePercentage, phaseTime) = await CalculatePhasePercentage(phase, cancellationToken);
|
||||
var (phasePercentage, phaseTime,phaseRemainingTime) = await CalculatePhasePercentage(phase, cancellationToken);
|
||||
phasePercentages.Add(phasePercentage);
|
||||
totalTime += phaseTime;
|
||||
remainingTime += phaseRemainingTime;
|
||||
}
|
||||
|
||||
var averagePercentage = phasePercentages.Any() ? (int)phasePercentages.Average() : 0;
|
||||
return (averagePercentage, totalTime);
|
||||
return (averagePercentage, totalTime,remainingTime);
|
||||
}
|
||||
|
||||
private async Task<(int Percentage, TimeSpan TotalTime)> CalculatePhasePercentage(ProjectPhase phase, CancellationToken cancellationToken)
|
||||
private async Task<(int Percentage, TimeSpan TotalTime,TimeSpan RemainingTime)> CalculatePhasePercentage(ProjectPhase phase,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var tasks = await _context.ProjectTasks
|
||||
.Where(t => t.PhaseId == phase.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
if (!tasks.Any())
|
||||
return (0, TimeSpan.Zero);
|
||||
return (0, TimeSpan.Zero,TimeSpan.Zero);
|
||||
var taskPercentages = new List<int>();
|
||||
var totalTime = TimeSpan.Zero;
|
||||
var remainingTime = TimeSpan.Zero;
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
var (taskPercentage, taskTime) = await CalculateTaskPercentage(task, cancellationToken);
|
||||
var (taskPercentage, taskTime,taskRemainingTime) = await CalculateTaskPercentage(task, cancellationToken);
|
||||
taskPercentages.Add(taskPercentage);
|
||||
totalTime += taskTime;
|
||||
remainingTime += taskRemainingTime;
|
||||
}
|
||||
|
||||
var averagePercentage = taskPercentages.Any() ? (int)taskPercentages.Average() : 0;
|
||||
return (averagePercentage, totalTime);
|
||||
return (averagePercentage, totalTime,remainingTime);
|
||||
}
|
||||
|
||||
private async Task<(int Percentage, TimeSpan TotalTime)> CalculateTaskPercentage(ProjectTask task, CancellationToken cancellationToken)
|
||||
private async Task<(int Percentage, TimeSpan TotalTime, TimeSpan RemainingTime)> CalculateTaskPercentage(
|
||||
ProjectTask task, CancellationToken cancellationToken)
|
||||
{
|
||||
var sections = await _context.TaskSections
|
||||
.Include(s => s.Activities)
|
||||
.Include(x=>x.AdditionalTimes)
|
||||
.Include(x => x.AdditionalTimes)
|
||||
.Where(s => s.TaskId == task.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
if (!sections.Any())
|
||||
return (0, TimeSpan.Zero);
|
||||
return (0, TimeSpan.Zero, TimeSpan.Zero);
|
||||
var sectionPercentages = new List<int>();
|
||||
var totalTime = TimeSpan.Zero;
|
||||
var spentTime = TimeSpan.Zero;
|
||||
foreach (var section in sections)
|
||||
{
|
||||
var (sectionPercentage, sectionTime) = CalculateSectionPercentage(section);
|
||||
var sectionSpent = TimeSpan.FromTicks(section.Activities.Sum(x => x.GetTimeSpent().Ticks));
|
||||
sectionPercentages.Add(sectionPercentage);
|
||||
totalTime += sectionTime;
|
||||
spentTime += sectionSpent;
|
||||
}
|
||||
var remainingTime = totalTime - spentTime;
|
||||
var averagePercentage = sectionPercentages.Any() ? (int)sectionPercentages.Average() : 0;
|
||||
return (averagePercentage, totalTime);
|
||||
return (averagePercentage, totalTime, remainingTime);
|
||||
}
|
||||
|
||||
private static (int Percentage, TimeSpan TotalTime) CalculateSectionPercentage(TaskSection section)
|
||||
{
|
||||
return ((int)section.GetProgressPercentage(),section.FinalEstimatedHours);
|
||||
return ((int)section.GetProgressPercentage(), section.FinalEstimatedHours);
|
||||
}
|
||||
|
||||
private static AssignmentStatus GetAssignmentStatus(TaskSection? section)
|
||||
@@ -341,7 +369,7 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
|
||||
// بررسی وجود user
|
||||
bool hasUser = section.CurrentAssignedUserId > 0;
|
||||
|
||||
|
||||
// بررسی وجود time (InitialEstimatedHours بزرگتر از صفر باشد)
|
||||
bool hasTime = section.InitialEstimatedHours > TimeSpan.Zero;
|
||||
|
||||
@@ -356,5 +384,4 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
// تعیین تکلیف نشده: نه user دارد نه time
|
||||
return AssignmentStatus.Unassigned;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,8 +9,8 @@ public class GetTaskDto
|
||||
public int Percentage { get; init; }
|
||||
public ProjectHierarchyLevel Level { get; init; }
|
||||
public Guid? ParentId { get; init; }
|
||||
public int TotalHours { get; set; }
|
||||
public int Minutes { get; set; }
|
||||
|
||||
public TimeSpan TotalTime { get; set; }
|
||||
|
||||
// Task-specific fields
|
||||
public TimeSpan SpentTime { get; init; }
|
||||
|
||||
@@ -7,6 +7,6 @@ namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.Project
|
||||
public record ProjectBoardListQuery: IBaseQuery<List<ProjectBoardListResponse>>
|
||||
{
|
||||
public long? UserId { get; set; }
|
||||
public string? SearchText { get; set; }
|
||||
public string? ProjectName { get; set; }
|
||||
public TaskSectionStatus? Status { get; set; }
|
||||
}
|
||||
@@ -46,11 +46,11 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler<ProjectBoardListQu
|
||||
queryable = queryable.Where(x => x.CurrentAssignedUserId == request.UserId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.SearchText))
|
||||
if (!string.IsNullOrWhiteSpace(request.ProjectName))
|
||||
{
|
||||
queryable = queryable.Where(x=>x.Task.Name.Contains(request.SearchText)
|
||||
|| x.Task.Phase.Name.Contains(request.SearchText)
|
||||
|| x.Task.Phase.Project.Name.Contains(request.SearchText));
|
||||
queryable = queryable.Where(x=>x.Task.Name.Contains(request.ProjectName)
|
||||
|| x.Task.Phase.Name.Contains(request.ProjectName)
|
||||
|| x.Task.Phase.Project.Name.Contains(request.ProjectName));
|
||||
}
|
||||
|
||||
var data = await queryable.ToListAsync(cancellationToken);
|
||||
@@ -70,6 +70,9 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler<ProjectBoardListQu
|
||||
.OrderByDescending(x => x.CurrentAssignedUserId == currentUserId)
|
||||
.ThenByDescending(x=>x.Task.Priority)
|
||||
.ThenBy(x => GetStatusOrder(x.Status))
|
||||
.ThenBy(x=>x.Task.Phase.ProjectId)
|
||||
.ThenBy(x=>x.Task.PhaseId)
|
||||
.ThenBy(x=>x.TaskId)
|
||||
.Select(x =>
|
||||
{
|
||||
// محاسبه یکبار برای هر Activity و Cache کردن نتیجه
|
||||
|
||||
@@ -3,6 +3,7 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
@@ -28,26 +28,25 @@ public class SendMessageCommandHandler : IBaseCommandHandler<SendMessageCommand,
|
||||
private readonly ITaskChatMessageRepository _messageRepository;
|
||||
private readonly IUploadedFileRepository _fileRepository;
|
||||
private readonly IProjectTaskRepository _taskRepository;
|
||||
private readonly IFileStorageService _fileStorageService;
|
||||
private readonly IThumbnailGeneratorService _thumbnailService;
|
||||
private readonly IFileUploadService _fileUploadService;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public SendMessageCommandHandler(
|
||||
ITaskChatMessageRepository messageRepository,
|
||||
IUploadedFileRepository fileRepository,
|
||||
IProjectTaskRepository taskRepository,
|
||||
IFileStorageService fileStorageService,
|
||||
IThumbnailGeneratorService thumbnailService, IAuthHelper authHelper)
|
||||
IProjectTaskRepository taskRepository,
|
||||
IAuthHelper authHelper,
|
||||
IFileUploadService fileUploadService)
|
||||
{
|
||||
_messageRepository = messageRepository;
|
||||
_fileRepository = fileRepository;
|
||||
_taskRepository = taskRepository;
|
||||
_fileStorageService = fileStorageService;
|
||||
_thumbnailService = thumbnailService;
|
||||
_authHelper = authHelper;
|
||||
_fileUploadService = fileUploadService;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<MessageDto>> Handle(SendMessageCommand request, CancellationToken cancellationToken)
|
||||
public async Task<OperationResult<MessageDto>> Handle(SendMessageCommand request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var currentUserId = _authHelper.GetCurrentUserId()
|
||||
?? throw new UnAuthorizedException("کاربر احراز هویت نشده است");
|
||||
@@ -57,75 +56,21 @@ public class SendMessageCommandHandler : IBaseCommandHandler<SendMessageCommand,
|
||||
{
|
||||
return OperationResult<MessageDto>.NotFound("تسک یافت نشد");
|
||||
}
|
||||
|
||||
|
||||
Guid? uploadedFileId = null;
|
||||
if (request.File != null)
|
||||
{
|
||||
if (request.File.Length == 0)
|
||||
{
|
||||
return OperationResult<MessageDto>.ValidationError("فایل خالی است");
|
||||
}
|
||||
|
||||
const long maxFileSize = 100 * 1024 * 1024;
|
||||
if (request.File.Length > maxFileSize)
|
||||
{
|
||||
return OperationResult<MessageDto>.ValidationError("حجم فایل بیش از حد مجاز است (حداکثر 100MB)");
|
||||
}
|
||||
|
||||
var fileType = DetectFileType(request.File.ContentType, Path.GetExtension(request.File.FileName));
|
||||
|
||||
var uploadedFile = new UploadedFile(
|
||||
originalFileName: request.File.FileName,
|
||||
fileSizeBytes: request.File.Length,
|
||||
mimeType: request.File.ContentType,
|
||||
fileType: fileType,
|
||||
category: FileCategory.TaskChatMessage,
|
||||
uploadedByUserId: currentUserId,
|
||||
storageProvider: StorageProvider.LocalFileSystem
|
||||
var uploadedFile = await _fileUploadService.UploadFileAsync
|
||||
(
|
||||
request.File,
|
||||
FileCategory.TaskChatMessage,
|
||||
currentUserId
|
||||
);
|
||||
|
||||
await _fileRepository.AddAsync(uploadedFile);
|
||||
await _fileRepository.SaveChangesAsync();
|
||||
|
||||
try
|
||||
if (!uploadedFile.IsSuccess)
|
||||
{
|
||||
using var stream = request.File.OpenReadStream();
|
||||
var uploadResult = await _fileStorageService.UploadAsync(
|
||||
stream,
|
||||
uploadedFile.UniqueFileName,
|
||||
"TaskChatMessage"
|
||||
);
|
||||
|
||||
uploadedFile.CompleteUpload(uploadResult.StoragePath, uploadResult.StorageUrl);
|
||||
|
||||
if (fileType == FileType.Image)
|
||||
{
|
||||
var dimensions = await _thumbnailService.GetImageDimensionsAsync(uploadResult.StoragePath);
|
||||
if (dimensions.HasValue)
|
||||
{
|
||||
uploadedFile.SetImageDimensions(dimensions.Value.Width, dimensions.Value.Height);
|
||||
}
|
||||
|
||||
var thumbnail = await _thumbnailService
|
||||
.GenerateImageThumbnailAsync(uploadResult.StoragePath, category: "TaskChatMessage");
|
||||
if (thumbnail.HasValue)
|
||||
{
|
||||
uploadedFile.SetThumbnail(thumbnail.Value.ThumbnailUrl);
|
||||
}
|
||||
}
|
||||
|
||||
await _fileRepository.UpdateAsync(uploadedFile);
|
||||
await _fileRepository.SaveChangesAsync();
|
||||
|
||||
uploadedFileId = uploadedFile.Id;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _fileRepository.DeleteAsync(uploadedFile);
|
||||
await _fileRepository.SaveChangesAsync();
|
||||
|
||||
return OperationResult<MessageDto>.ValidationError($"خطا در آپلود فایل: {ex.Message}");
|
||||
return OperationResult<MessageDto>.Failure(uploadedFile.ErrorMessage ?? "خطا در آپلود فایل");
|
||||
}
|
||||
uploadedFileId = uploadedFile.FileId!.Value;
|
||||
}
|
||||
|
||||
var message = new TaskChatMessage(
|
||||
@@ -209,4 +154,4 @@ public class SendMessageCommandHandler : IBaseCommandHandler<SendMessageCommand,
|
||||
|
||||
return FileType.Document;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Enums;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -28,7 +29,7 @@ public class GetMessagesQueryHandler : IBaseQueryHandler<GetMessagesQuery, Pagin
|
||||
}
|
||||
|
||||
private List<MessageDto> CreateAdditionalTimeNotes(
|
||||
IEnumerable<Domain.ProjectAgg.Entities.TaskSectionAdditionalTime> additionalTimes,
|
||||
IEnumerable<TaskSectionAdditionalTime> additionalTimes,
|
||||
Dictionary<long, string> users,
|
||||
Guid taskId)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
||||
using GozareshgirProgramManager.Application.Services.FileManagement;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.CreateTaskSectionRevision;
|
||||
|
||||
public record CreateTaskSectionRevisionCommand(string Message, List<IFormFile> Files, Guid SectionId) : IBaseCommand;
|
||||
|
||||
public class CreateTaskSectionRevisionCommandHandler : IBaseCommandHandler<CreateTaskSectionRevisionCommand>
|
||||
{
|
||||
private readonly ITaskSectionRevisionRepository _revisionRepository;
|
||||
private readonly IFileStorageService _fileStorageService;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IUploadedFileRepository _fileRepository;
|
||||
private readonly IThumbnailGeneratorService _thumbnailService;
|
||||
|
||||
public CreateTaskSectionRevisionCommandHandler(ITaskSectionRevisionRepository revisionRepository,
|
||||
IFileStorageService fileStorageService, IAuthHelper authHelper, IUnitOfWork unitOfWork, IUploadedFileRepository fileRepository, IThumbnailGeneratorService thumbnailService)
|
||||
{
|
||||
_revisionRepository = revisionRepository;
|
||||
_fileStorageService = fileStorageService;
|
||||
_authHelper = authHelper;
|
||||
_unitOfWork = unitOfWork;
|
||||
_fileRepository = fileRepository;
|
||||
_thumbnailService = thumbnailService;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(CreateTaskSectionRevisionCommand request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var currentId = _authHelper.GetCurrentUserId();
|
||||
|
||||
var entity = new Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionRevision(request.SectionId, request.Message, currentId!.Value);
|
||||
if (request.Files is { Count: > 0 })
|
||||
{
|
||||
foreach (var file in request.Files)
|
||||
{
|
||||
if (file.Length == 0)
|
||||
{
|
||||
return OperationResult.ValidationError("فایل خالی است");
|
||||
}
|
||||
|
||||
const long maxFileSize = 100 * 1024 * 1024;
|
||||
if (file.Length > maxFileSize)
|
||||
{
|
||||
return OperationResult.ValidationError("حجم فایل بیش از حد مجاز است (حداکثر 100MB)");
|
||||
}
|
||||
|
||||
var fileType = DetectFileType(file.ContentType, Path.GetExtension(file.FileName));
|
||||
|
||||
var uploadedFile = new UploadedFile(
|
||||
originalFileName: file.FileName,
|
||||
fileSizeBytes: file.Length,
|
||||
mimeType: file.ContentType,
|
||||
fileType: fileType,
|
||||
category: FileCategory.TaskSectionRevision,
|
||||
uploadedByUserId: currentId!.Value,
|
||||
storageProvider: StorageProvider.LocalFileSystem
|
||||
);
|
||||
|
||||
await _fileRepository.AddAsync(uploadedFile);
|
||||
await _fileRepository.SaveChangesAsync();
|
||||
|
||||
try
|
||||
{
|
||||
await using var stream = file.OpenReadStream();
|
||||
var uploadResult = await _fileStorageService.UploadAsync(
|
||||
stream,
|
||||
uploadedFile.UniqueFileName,
|
||||
"TaskSectionRevision"
|
||||
);
|
||||
|
||||
uploadedFile.CompleteUpload(uploadResult.StoragePath, uploadResult.StorageUrl);
|
||||
|
||||
if (fileType == FileType.Image)
|
||||
{
|
||||
var dimensions = await _thumbnailService.GetImageDimensionsAsync(uploadResult.StoragePath);
|
||||
if (dimensions.HasValue)
|
||||
{
|
||||
uploadedFile.SetImageDimensions(dimensions.Value.Width, dimensions.Value.Height);
|
||||
}
|
||||
|
||||
var thumbnail = await _thumbnailService
|
||||
.GenerateImageThumbnailAsync(uploadResult.StoragePath, category: "TaskSectionRevision");
|
||||
if (thumbnail.HasValue)
|
||||
{
|
||||
uploadedFile.SetThumbnail(thumbnail.Value.ThumbnailUrl);
|
||||
}
|
||||
}
|
||||
|
||||
await _fileRepository.UpdateAsync(uploadedFile);
|
||||
await _fileRepository.SaveChangesAsync();
|
||||
|
||||
var taskRevisionFile = new TaskRevisionFile(uploadedFile.Id);
|
||||
entity.AddFile(taskRevisionFile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _fileRepository.DeleteAsync(uploadedFile);
|
||||
await _fileRepository.SaveChangesAsync();
|
||||
|
||||
return OperationResult<MessageDto>.ValidationError($"خطا در آپلود فایل: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await _revisionRepository.CreateAsync(entity);
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return OperationResult.Success();
|
||||
}
|
||||
private FileType DetectFileType(string mimeType, string extension)
|
||||
{
|
||||
if (mimeType.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
|
||||
return FileType.Image;
|
||||
|
||||
if (mimeType.StartsWith("video/", StringComparison.OrdinalIgnoreCase))
|
||||
return FileType.Video;
|
||||
|
||||
if (mimeType.StartsWith("audio/", StringComparison.OrdinalIgnoreCase))
|
||||
return FileType.Audio;
|
||||
|
||||
if (new[] { ".zip", ".rar", ".7z", ".tar", ".gz" }.Contains(extension.ToLower()))
|
||||
return FileType.Archive;
|
||||
|
||||
return FileType.Document;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using FluentValidation;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.CreateTaskSectionRevision;
|
||||
|
||||
public class CreateTaskSectionRevisionValidator:AbstractValidator<CreateTaskSectionRevisionCommand>
|
||||
{
|
||||
public CreateTaskSectionRevisionValidator()
|
||||
{
|
||||
RuleFor(x=>x.Message)
|
||||
.NotEmpty()
|
||||
.WithMessage("توضیحات اجباری است");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.SetStatusReviewedRevision;
|
||||
|
||||
public record SetStatusReviewedRevisionCommand(Guid TaskSectionId):IBaseCommand;
|
||||
|
||||
public class SetStatusReviewedRevisionCommandHandler : IBaseCommandHandler<SetStatusReviewedRevisionCommand>
|
||||
{
|
||||
private readonly ITaskSectionRevisionRepository _revisionRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public SetStatusReviewedRevisionCommandHandler(ITaskSectionRevisionRepository revisionRepository, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_revisionRepository = revisionRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(SetStatusReviewedRevisionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var taskSectionRevisions = await _revisionRepository.GetByTaskSectionId(request.TaskSectionId);
|
||||
if (taskSectionRevisions == null || taskSectionRevisions.Count == 0)
|
||||
return OperationResult.NotFound("اصلاحی برای این بخش یافت نشد");
|
||||
|
||||
foreach (var revision in taskSectionRevisions)
|
||||
{
|
||||
revision.MarkReviewed();
|
||||
}
|
||||
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return OperationResult.Success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Queries.TaskRevisionsByTaskSectionId;
|
||||
|
||||
public record TaskRevisionsByTaskSectionIdQuery(Guid TaskSectionId)
|
||||
: IBaseQuery<TaskRevisionsByTaskSectionIdResponse>;
|
||||
|
||||
public class TaskRevisionsByTaskSectionIdQueryHandler : IBaseQueryHandler<TaskRevisionsByTaskSectionIdQuery,
|
||||
TaskRevisionsByTaskSectionIdResponse>
|
||||
{
|
||||
private readonly IProgramManagerDbContext _dbContext;
|
||||
|
||||
public TaskRevisionsByTaskSectionIdQueryHandler(IProgramManagerDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<TaskRevisionsByTaskSectionIdResponse>> Handle(
|
||||
TaskRevisionsByTaskSectionIdQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var taskSectionEntity = await _dbContext.TaskSections
|
||||
.Include(x=>x.Task)
|
||||
.ThenInclude(x => x.Phase)
|
||||
.ThenInclude(x => x.Project)
|
||||
.FirstOrDefaultAsync(x => x.Id == request.TaskSectionId,
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
if (taskSectionEntity == null)
|
||||
{
|
||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.NotFound("بخش فرعی یافت نشد");
|
||||
}
|
||||
|
||||
var taskRevisions = await _dbContext.TaskSectionRevisions
|
||||
.Include(x => x.Files).Where(x => x.TaskSectionId == request.TaskSectionId)
|
||||
.ToListAsync(cancellationToken);
|
||||
if (taskRevisions.Count == 0)
|
||||
{
|
||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.NotFound("اصلاحی یافت نشد");
|
||||
}
|
||||
|
||||
var skill = await _dbContext.Skills.FirstOrDefaultAsync(x => x.Id == taskSectionEntity.SkillId,
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
if (skill == null)
|
||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.NotFound("مهارت مورد نظر یافت نشد");
|
||||
|
||||
|
||||
var user =await _dbContext.Users.FirstOrDefaultAsync(x => x.Id == taskSectionEntity.CurrentAssignedUserId,
|
||||
cancellationToken: cancellationToken);
|
||||
if (user == null)
|
||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.NotFound("کاربر مورد نظر یافت نشد");
|
||||
|
||||
var fileIds = taskRevisions.SelectMany(x => x.Files)
|
||||
.Select(x => x.FileId).Distinct().ToList();
|
||||
|
||||
var uploadedFiles = _dbContext.UploadedFiles
|
||||
.Where(x => fileIds.Contains(x.Id)).ToList();
|
||||
|
||||
var resItems = taskRevisions.Select(x =>
|
||||
{
|
||||
var itemFileIds = x.Files.Select(f => f.FileId).Distinct().ToList();
|
||||
|
||||
var files = uploadedFiles
|
||||
.Where(f => itemFileIds.Contains(f.Id))
|
||||
.Select(file => new TaskRevisionsByTaskSectionIdItemFile()
|
||||
{
|
||||
Id = file.Id,
|
||||
FileName = file.OriginalFileName,
|
||||
FileUrl = file.StorageUrl ?? "",
|
||||
FileSizeBytes = file.FileSizeBytes,
|
||||
FileType = file.FileType.ToString(),
|
||||
ThumbnailUrl = file.ThumbnailUrl,
|
||||
ImageWidth = file.ImageWidth,
|
||||
ImageHeight = file.ImageHeight,
|
||||
DurationSeconds = file.DurationSeconds
|
||||
}).ToList();
|
||||
|
||||
return new TaskRevisionsByTaskSectionIdItem(x.Message, files,$"{x.CreationDate.ToFarsi()} {x.CreationDate:HH:mm}");
|
||||
}).ToList();
|
||||
|
||||
var res = new TaskRevisionsByTaskSectionIdResponse(resItems, taskSectionEntity.Task.Phase.Project.Name,
|
||||
taskSectionEntity.Task.Phase.Name, taskSectionEntity.Task.Name,
|
||||
skill.Name,
|
||||
user.FullName
|
||||
);
|
||||
|
||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.Success(res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Queries.TaskRevisionsByTaskSectionId;
|
||||
|
||||
public record TaskRevisionsByTaskSectionIdResponse(
|
||||
List<TaskRevisionsByTaskSectionIdItem> Items,
|
||||
string ProjectName,
|
||||
string PhaseName,
|
||||
string TaskName,
|
||||
string SkillName,
|
||||
string UserName);
|
||||
|
||||
|
||||
public record TaskRevisionsByTaskSectionIdItem(string Message, List<TaskRevisionsByTaskSectionIdItemFile> Files,string CreationDate);
|
||||
|
||||
public class TaskRevisionsByTaskSectionIdItemFile:UploadedFileDto;
|
||||
@@ -0,0 +1,56 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.AcceptTimeRequest;
|
||||
|
||||
public record AcceptTimeRequestCommand(Guid TimeRequestId,
|
||||
Guid SectionId,TaskSectionAdditionalTimeType TimeType,int Hour,int Minute):IBaseCommand;
|
||||
|
||||
public class AcceptTimeRequestCommandHandler:IBaseCommandHandler<AcceptTimeRequestCommand>
|
||||
{
|
||||
private readonly ITaskSectionTimeRequestRepository _timeRequestRepository;
|
||||
private readonly ITaskSectionRepository _taskSectionRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public AcceptTimeRequestCommandHandler(ITaskSectionTimeRequestRepository timeRequestRepository, ITaskSectionRepository taskSectionRepository, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_timeRequestRepository = timeRequestRepository;
|
||||
_taskSectionRepository = taskSectionRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(AcceptTimeRequestCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var timeRequest = await _timeRequestRepository.GetByIdAsync(request.TimeRequestId, cancellationToken);
|
||||
if (timeRequest == null)
|
||||
{
|
||||
return OperationResult.NotFound("درخواست زمان شما یافت نشد");
|
||||
}
|
||||
|
||||
var taskSection = await _taskSectionRepository.GetByIdAsync(request.SectionId, cancellationToken);
|
||||
|
||||
if (taskSection == null)
|
||||
{
|
||||
return OperationResult.NotFound("بخش فرعی وارد شده نامعتبر است");
|
||||
}
|
||||
if (timeRequest.RequestStatus == TaskSectionTimeRequestStatus.Accepted)
|
||||
{
|
||||
return OperationResult.Failure("این درخواست قبلا تایید شده است");
|
||||
}
|
||||
|
||||
// تایید درخواست زمان
|
||||
timeRequest.AcceptTimeRequest();
|
||||
|
||||
// اضافه کردن زمان به TaskSection
|
||||
var totalMinutes = (request.Hour * 60) + request.Minute;
|
||||
var additionalTime = TimeSpan.FromMinutes(totalMinutes);
|
||||
taskSection.AddAdditionalTime(additionalTime, request.TimeType, timeRequest.Description);
|
||||
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return OperationResult.Success();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.AcceptTimeRequest;
|
||||
|
||||
public class AcceptTimeRequestCommandValidator : AbstractValidator<AcceptTimeRequestCommand>
|
||||
{
|
||||
public AcceptTimeRequestCommandValidator()
|
||||
{
|
||||
RuleFor(c => c.TimeRequestId)
|
||||
.NotEmpty().WithMessage("شناسه درخواست نمیتواند خالی باشد");
|
||||
|
||||
RuleFor(c => c.SectionId)
|
||||
.NotEmpty().WithMessage("شناسه بخش فرعی نمیتواند خالی باشد");
|
||||
|
||||
RuleFor(c => c.TimeType)
|
||||
.NotNull().WithMessage("نوع زمان درخواست شده نامعتبر است")
|
||||
.IsInEnum();
|
||||
|
||||
RuleFor(c => c.Hour)
|
||||
.InclusiveBetween(0, 100).WithMessage("ساعت وارد شده میتواند بین 0 تا 100 باشد");
|
||||
RuleFor(c => c.Minute)
|
||||
.InclusiveBetween(0, 60).WithMessage("دقیقه وارد شده میتواند بین 0 تا 60 باشد");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.CreateTimeRequest;
|
||||
|
||||
public record CreateTimeRequestCommand(int Hours, int Minutes, string Description,
|
||||
TaskSectionTimeRequestType RequestType,Guid TaskSectionId) : IBaseCommand;
|
||||
|
||||
public class CreateTimeRequestCommandHandler : IBaseCommandHandler<CreateTimeRequestCommand>
|
||||
{
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly ITaskSectionTimeRequestRepository _timeRequestRepository;
|
||||
private readonly ITaskSectionRepository _taskSectionRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CreateTimeRequestCommandHandler
|
||||
(ITaskSectionTimeRequestRepository timeRequestRepository, IAuthHelper authHelper, IUnitOfWork unitOfWork, ITaskSectionRepository taskSectionRepository)
|
||||
{
|
||||
_timeRequestRepository = timeRequestRepository;
|
||||
_authHelper = authHelper;
|
||||
_unitOfWork = unitOfWork;
|
||||
_taskSectionRepository = taskSectionRepository;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(CreateTimeRequestCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var currentUser = _authHelper.GetCurrentUserId();
|
||||
if (!currentUser.HasValue)
|
||||
{
|
||||
return OperationResult.Unauthorized();
|
||||
}
|
||||
|
||||
if (!_taskSectionRepository.Exists(x=>x.Id == request.TaskSectionId))
|
||||
{
|
||||
return OperationResult.NotFound("وظیفه فرعی مورد نظر یافت نشد");
|
||||
}
|
||||
|
||||
|
||||
var requestTimeSpan = TimeSpan.FromHours(request.Hours) + TimeSpan.FromMinutes(request.Minutes);
|
||||
|
||||
var entity = new TaskSectionTimeRequest(currentUser.Value, request.Description, requestTimeSpan,
|
||||
request.RequestType,request.TaskSectionId);
|
||||
await _timeRequestRepository.CreateAsync(entity);
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return OperationResult.Success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.CreateTimeRequest;
|
||||
|
||||
public class CreateTimeRequestValidator : AbstractValidator<CreateTimeRequestCommand>
|
||||
{
|
||||
public CreateTimeRequestValidator()
|
||||
{
|
||||
RuleFor(c => c.Hours)
|
||||
.InclusiveBetween(0, 100).WithMessage("ساعت درخواست شده باید کمتر از 100 ساعت باشد");
|
||||
|
||||
RuleFor(c => c.Minutes)
|
||||
.InclusiveBetween(0, 59)
|
||||
.WithMessage("دقیقه وارد شده باید بین 0 تا 60 باشد");
|
||||
|
||||
RuleFor(x => x.RequestType)
|
||||
.IsInEnum()
|
||||
.NotNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using GozareshgirProgramManager.Application._Common.Extensions;
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Queries.CreateTimeRequestDetails;
|
||||
|
||||
public record CreateTimeRequestDetailsResponse(List<CreateTimeRequestDetailsRevision> Revisions);
|
||||
|
||||
public record CreateTimeRequestDetailsRevision(string Message, List<UploadedFileDto> Files);
|
||||
|
||||
public record CreateTimeRequestDetailsQuery(Guid TaskSectionId) : IBaseQuery<CreateTimeRequestDetailsResponse>;
|
||||
|
||||
public class
|
||||
CreateTimeRequestDetailsQueryHandler : IBaseQueryHandler<CreateTimeRequestDetailsQuery,
|
||||
CreateTimeRequestDetailsResponse>
|
||||
{
|
||||
private readonly IProgramManagerDbContext _context;
|
||||
|
||||
public CreateTimeRequestDetailsQueryHandler(IProgramManagerDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<CreateTimeRequestDetailsResponse>> Handle(CreateTimeRequestDetailsQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var revisions = await _context.TaskSectionRevisions.Where(x =>
|
||||
x.TaskSectionId == request.TaskSectionId && x.Status == RevisionReviewStatus.Pending).ToListAsync(cancellationToken: cancellationToken);
|
||||
|
||||
var fileIds = revisions.SelectMany(x => x.Files)
|
||||
.Select(x => x.Id).ToList();
|
||||
|
||||
var files =await _context.UploadedFiles
|
||||
.Where(x => fileIds.Contains(x.Id)).ToListAsync(cancellationToken: cancellationToken);
|
||||
|
||||
var resItem = revisions.Select(x =>
|
||||
{
|
||||
var selectFileIds = x.Files.Select(f => f.FileId).ToList();
|
||||
var filesDto = files.Where(f => selectFileIds.Contains(f.Id))
|
||||
.Select(f => f.ToDto()).ToList();
|
||||
return new CreateTimeRequestDetailsRevision(x.Message, filesDto);
|
||||
}).ToList();
|
||||
var res = new CreateTimeRequestDetailsResponse(resItem);
|
||||
|
||||
return OperationResult<CreateTimeRequestDetailsResponse>.Success(res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
||||
|
||||
public interface IWorkflowProvider
|
||||
{
|
||||
WorkflowType Type { get; }
|
||||
Task<List<WorkflowListItem>> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken);
|
||||
Task<int> GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
||||
|
||||
public class BugSectionWorkflowProvider : IWorkflowProvider
|
||||
{
|
||||
public WorkflowType Type => WorkflowType.BugSection;
|
||||
public async Task<List<WorkflowListItem>> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var bugs =context.BugSections
|
||||
.Where(b=>b.Status == TaskSectionStatus.ReadyToStart)
|
||||
.Include(x => x.ProjectTask).AsNoTracking();
|
||||
|
||||
return await bugs.Select(x => new WorkflowListItem
|
||||
{
|
||||
EntityId = x.Id,
|
||||
Title = x.ProjectTask.Name,
|
||||
Type = WorkflowType.BugSection
|
||||
}).ToListAsync(cancellationToken);
|
||||
|
||||
}
|
||||
|
||||
public async Task<int> GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = context.BugSections
|
||||
.Where(b => b.Status == TaskSectionStatus.ReadyToStart);
|
||||
|
||||
return await query.CountAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
||||
|
||||
public class NotAssignedWorkflowProvider : IWorkflowProvider
|
||||
{
|
||||
public WorkflowType Type => WorkflowType.NotAssigned;
|
||||
|
||||
public async Task<List<WorkflowListItem>> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
// Assuming 0 means unassigned in CurrentAssignedUserId
|
||||
var sections = await context.TaskSections
|
||||
.Where(x => x.CurrentAssignedUserId == 0)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return sections.Select(ts => new WorkflowListItem
|
||||
{
|
||||
EntityId = ts.Id,
|
||||
Title = "تخصیص نیافته",
|
||||
Type = WorkflowType.NotAssigned
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public async Task<int> GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
return await context.TaskSections
|
||||
.Where(x => x.CurrentAssignedUserId == 0)
|
||||
.CountAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
||||
|
||||
public class RejectedRevisionsWorkflowProvider : IWorkflowProvider
|
||||
{
|
||||
public WorkflowType Type => WorkflowType.Rejected;
|
||||
|
||||
public async Task<List<WorkflowListItem>> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = from revision in context.TaskSectionRevisions
|
||||
.Where(x => x.Status == RevisionReviewStatus.Pending)
|
||||
join taskSection in context.TaskSections
|
||||
on revision.TaskSectionId equals taskSection.Id
|
||||
where taskSection.CurrentAssignedUserId == currentUserId
|
||||
select taskSection;
|
||||
|
||||
var sections = await query.ToListAsync(cancellationToken);
|
||||
|
||||
return sections.Select(ts => new WorkflowListItem
|
||||
{
|
||||
EntityId = ts.Id,
|
||||
Title = "برگشت از سمت مدیر",
|
||||
Type = WorkflowType.Rejected
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public async Task<int> GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = from revision in context.TaskSectionRevisions
|
||||
.Where(x => x.Status == RevisionReviewStatus.Pending)
|
||||
join taskSection in context.TaskSections
|
||||
on revision.TaskSectionId equals taskSection.Id
|
||||
where taskSection.CurrentAssignedUserId == currentUserId
|
||||
select revision.Id;
|
||||
|
||||
return await query.CountAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
||||
|
||||
public record WorkflowCountResponse(int Total, int Rejected, int NotAssigned, int PendingForApproval);
|
||||
|
||||
public record WorkflowCountQuery() : IBaseQuery<WorkflowCountResponse>;
|
||||
|
||||
public class WorkflowCountQueryHandler : IBaseQueryHandler<WorkflowCountQuery, WorkflowCountResponse>
|
||||
{
|
||||
private readonly IProgramManagerDbContext _context;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IEnumerable<IWorkflowProvider> _providers;
|
||||
|
||||
public WorkflowCountQueryHandler(IProgramManagerDbContext context, IAuthHelper authHelper, IEnumerable<IWorkflowProvider> providers)
|
||||
{
|
||||
_context = context;
|
||||
_authHelper = authHelper;
|
||||
_providers = providers;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<WorkflowCountResponse>> Handle(WorkflowCountQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
long currentUserId = _authHelper.GetCurrentUserId()!.Value;
|
||||
|
||||
int rejectedCount = 0;
|
||||
int notAssignedCount = 0;
|
||||
int pendingForApprovalCount = 0;
|
||||
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
var count = await provider.GetCount(currentUserId, _context, cancellationToken);
|
||||
switch (provider.Type)
|
||||
{
|
||||
case WorkflowType.Rejected:
|
||||
rejectedCount += count; break;
|
||||
case WorkflowType.NotAssigned:
|
||||
notAssignedCount += count; break;
|
||||
case WorkflowType.PendingForApproval:
|
||||
pendingForApprovalCount += count; break;
|
||||
}
|
||||
}
|
||||
|
||||
var total = rejectedCount + notAssignedCount + pendingForApprovalCount;
|
||||
var response = new WorkflowCountResponse(total, rejectedCount, notAssignedCount, pendingForApprovalCount);
|
||||
return OperationResult<WorkflowCountResponse>.Success(response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
||||
|
||||
public record WorkflowListResponse(List<WorkflowListItem>Items);
|
||||
|
||||
public class WorkflowListItem
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public WorkflowType Type { get; set; }
|
||||
public Guid EntityId { get; set; }
|
||||
}
|
||||
|
||||
public enum WorkflowType
|
||||
{
|
||||
Rejected,
|
||||
NotAssigned,
|
||||
PendingForApproval,
|
||||
BugSection,
|
||||
}
|
||||
|
||||
public record WorkflowListQuery():IBaseQuery<WorkflowListResponse>;
|
||||
|
||||
public class WorkflowListQueryHandler:IBaseQueryHandler<WorkflowListQuery,WorkflowListResponse>
|
||||
{
|
||||
private readonly IProgramManagerDbContext _context;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IEnumerable<IWorkflowProvider> _providers;
|
||||
|
||||
public WorkflowListQueryHandler(IProgramManagerDbContext context,
|
||||
IAuthHelper authHelper,
|
||||
IEnumerable<IWorkflowProvider> providers)
|
||||
{
|
||||
_context = context;
|
||||
_authHelper = authHelper;
|
||||
_providers = providers;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<WorkflowListResponse>> Handle(WorkflowListQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var currentUserId = _authHelper.GetCurrentUserId()!.Value;
|
||||
var items = new List<WorkflowListItem>();
|
||||
var response = new WorkflowListResponse(items);
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
var providerItems = await provider.GetItems(currentUserId, _context, cancellationToken);
|
||||
if (providerItems?.Count > 0)
|
||||
items.AddRange(providerItems);
|
||||
}
|
||||
|
||||
return OperationResult<WorkflowListResponse>.Success(response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Enums;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Services.FileManagement;
|
||||
|
||||
/// <summary>
|
||||
/// سرویس آپلود و مدیریت کامل فایل
|
||||
/// این سرویس تمام مراحل آپلود، ذخیره، تولید thumbnail و... را انجام میدهد
|
||||
/// </summary>
|
||||
public interface IFileUploadService
|
||||
{
|
||||
/// <summary>
|
||||
/// آپلود فایل با تمام مراحل پردازش
|
||||
/// </summary>
|
||||
/// <param name="file">فایل برای آپلود</param>
|
||||
/// <param name="category">دستهبندی فایل</param>
|
||||
/// <param name="uploadedByUserId">شناسه کاربر آپلودکننده</param>
|
||||
/// <param name="maxFileSizeBytes">حداکثر حجم مجاز فایل (پیشفرض: 100MB)</param>
|
||||
/// <returns>شناسه فایل آپلود شده یا null در صورت خطا</returns>
|
||||
Task<FileUploadResult> UploadFileAsync(
|
||||
IFormFile file,
|
||||
FileCategory category,
|
||||
long uploadedByUserId,
|
||||
long maxFileSizeBytes = 100 * 1024 * 1024);
|
||||
|
||||
/// <summary>
|
||||
/// آپلود فایل با Stream
|
||||
/// </summary>
|
||||
Task<FileUploadResult> UploadFileFromStreamAsync(
|
||||
Stream fileStream,
|
||||
string fileName,
|
||||
string contentType,
|
||||
FileCategory category,
|
||||
long uploadedByUserId,
|
||||
long maxFileSizeBytes = 100 * 1024 * 1024);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// نتیجه عملیات آپلود فایل
|
||||
/// </summary>
|
||||
public class FileUploadResult
|
||||
{
|
||||
public bool IsSuccess { get; set; }
|
||||
public Guid? FileId { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public string? StorageUrl { get; set; }
|
||||
public string? ThumbnailUrl { get; set; }
|
||||
|
||||
public static FileUploadResult Success(Guid fileId, string storageUrl, string? thumbnailUrl = null)
|
||||
{
|
||||
return new FileUploadResult
|
||||
{
|
||||
IsSuccess = true,
|
||||
FileId = fileId,
|
||||
StorageUrl = storageUrl,
|
||||
ThumbnailUrl = thumbnailUrl
|
||||
};
|
||||
}
|
||||
|
||||
public static FileUploadResult Failed(string errorMessage)
|
||||
{
|
||||
return new FileUploadResult
|
||||
{
|
||||
IsSuccess = false,
|
||||
ErrorMessage = errorMessage
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +149,22 @@ public static class ProgramManagerPermissionCode
|
||||
{
|
||||
public const int Code = 990111;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// اولویت بندی
|
||||
/// </summary>
|
||||
public static class Priority
|
||||
{
|
||||
public const int Code = 990112;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد تسک باگ
|
||||
/// </summary>
|
||||
public static class CreateBug
|
||||
{
|
||||
public const int Code = 990113;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -226,11 +242,26 @@ public static class ProgramManagerPermissionCode
|
||||
{
|
||||
public const int Code = 990208;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// رد با تایید اتمام اجرا
|
||||
/// </summary>
|
||||
public static class RejectOrApproveTaskComplete
|
||||
{
|
||||
public const int Code = 990209;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Workflow[تب کارپوشه]
|
||||
public static class Workflow
|
||||
{
|
||||
public const int Code = 9903;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public static Dictionary<string, object> GetAllCodes()
|
||||
{
|
||||
var result = new Dictionary<string, object>();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
||||
|
||||
namespace GozareshgirProgramManager.Application._Common.Extensions;
|
||||
|
||||
public static class FileExtensions
|
||||
{
|
||||
public static UploadedFileDto ToDto(this UploadedFile file)
|
||||
{
|
||||
return new UploadedFileDto()
|
||||
{
|
||||
Id = file.Id,
|
||||
FileName = file.OriginalFileName,
|
||||
FileUrl = file.StorageUrl ?? "",
|
||||
FileSizeBytes = file.FileSizeBytes,
|
||||
FileType = file.FileType.ToString(),
|
||||
ThumbnailUrl = file.ThumbnailUrl,
|
||||
ImageWidth = file.ImageWidth,
|
||||
ImageHeight = file.ImageHeight,
|
||||
DurationSeconds = file.DurationSeconds
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@ using GozareshgirProgramManager.Domain.UserAgg.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
namespace GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
|
||||
@@ -25,12 +29,18 @@ public interface IProgramManagerDbContext
|
||||
DbSet<TaskSection> TaskSections { get; set; }
|
||||
DbSet<ProjectSection> ProjectSections { get; set; }
|
||||
DbSet<PhaseSection> PhaseSections { get; set; }
|
||||
|
||||
DbSet<BugSection> BugSections { get; set; }
|
||||
DbSet<ProjectTask> ProjectTasks { get; set; }
|
||||
|
||||
DbSet<TaskChatMessage> TaskChatMessages { get; set; }
|
||||
DbSet<UploadedFile> UploadedFiles { get; set; }
|
||||
|
||||
//Task Section Time Request
|
||||
DbSet<TaskSectionTimeRequest> TaskSectionTimeRequests { get; set; }
|
||||
|
||||
// Task Section Revision
|
||||
DbSet<TaskSectionRevision> TaskSectionRevisions { get; set; }
|
||||
|
||||
DbSet<Skill> Skills { get; set; }
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class OperationResult
|
||||
|
||||
// Helper methods for specific error types
|
||||
public static OperationResult NotFound(string errorMessage) => new(false, errorMessage, errorType: ErrorType.NotFound);
|
||||
public static OperationResult Unauthorized(string errorMessage) => new(false, errorMessage, errorType: ErrorType.Unauthorized);
|
||||
public static OperationResult Unauthorized(string errorMessage="احراز هویت شما منقضی شده است. لطفا دوباره وارد شوید") => new(false, errorMessage, errorType: ErrorType.Unauthorized);
|
||||
public static OperationResult ValidationError(string errorMessage) => new(false, errorMessage, errorType: ErrorType.Validation);
|
||||
public static OperationResult ValidationError(List<string> errors) => new(false, errors: errors, errorType: ErrorType.Validation);
|
||||
public static OperationResult InternalServerError(string errorMessage) => new(false, errorMessage, errorType: ErrorType.InternalServerError);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace GozareshgirProgramManager.Application._Common.Models;
|
||||
|
||||
public class UploadedFileDto
|
||||
{
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string FileUrl { get; set; } = string.Empty;
|
||||
public long FileSizeBytes { get; set; }
|
||||
public string FileType { get; set; } = string.Empty;
|
||||
public string? ThumbnailUrl { get; set; }
|
||||
public int? ImageWidth { get; set; }
|
||||
public int? ImageHeight { get; set; }
|
||||
public int? DurationSeconds { get; set; }
|
||||
|
||||
public string FileSizeFormatted
|
||||
{
|
||||
get
|
||||
{
|
||||
const long kb = 1024;
|
||||
const long mb = kb * 1024;
|
||||
const long gb = mb * 1024;
|
||||
|
||||
if (FileSizeBytes >= gb)
|
||||
return $"{FileSizeBytes / (double)gb:F2} GB";
|
||||
if (FileSizeBytes >= mb)
|
||||
return $"{FileSizeBytes / (double)mb:F2} MB";
|
||||
if (FileSizeBytes >= kb)
|
||||
return $"{FileSizeBytes / (double)kb:F2} KB";
|
||||
|
||||
return $"{FileSizeBytes} Bytes";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ public enum FileCategory
|
||||
ProjectDocument = 3, // مستندات پروژه
|
||||
UserProfilePhoto = 4, // عکس پروفایل کاربر
|
||||
Report = 5, // گزارش
|
||||
Other = 6 // سایر
|
||||
Other = 6, // سایر
|
||||
BugSection = 7, // تسک باگ
|
||||
TaskSectionRevision
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
|
||||
public class BugDocument
|
||||
{
|
||||
|
||||
public BugDocument(Guid fileId)
|
||||
{
|
||||
FileId = fileId;
|
||||
}
|
||||
private BugDocument() { } // EF
|
||||
public Guid Id { get; private set; }
|
||||
public Guid FileId { get; private set; }
|
||||
public BugSection BugSection { get; private set; }
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
|
||||
public class BugSection : EntityBase<Guid>
|
||||
{
|
||||
public BugSection(Guid taskId, string initialDescription, long originalAssignedUserId, ProjectTaskPriority priority)
|
||||
{
|
||||
TaskId = taskId;
|
||||
InitialDescription = initialDescription;
|
||||
Status = TaskSectionStatus.ReadyToStart;
|
||||
OriginalAssignedUserId = originalAssignedUserId;
|
||||
Priority = priority;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// برای EF Core
|
||||
private BugSection()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// آی دی تسک - بخش فرعی
|
||||
/// </summary>
|
||||
public Guid TaskId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// توضیحات مدیر
|
||||
/// </summary>
|
||||
public string InitialDescription { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت باگ گزارش شده
|
||||
/// </summary>
|
||||
public TaskSectionStatus Status { get; private set; }
|
||||
|
||||
|
||||
// شخصی که برای اولین بار این بخش به او اختصاص داده شده (مالک اصلی)
|
||||
public long OriginalAssignedUserId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// اولویت رسیدگی
|
||||
/// </summary>
|
||||
public ProjectTaskPriority Priority { get; private set; }
|
||||
|
||||
// Navigation to ProjectTask (must be Task level)
|
||||
public ProjectTask ProjectTask { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// لیست مدارک و فایلها
|
||||
/// </summary>
|
||||
public List<BugDocument> BugDocuments { get; private set; } = new();
|
||||
|
||||
public void AddDocument(BugDocument document)
|
||||
{
|
||||
BugDocuments.Add(document);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
|
||||
/// <summary>
|
||||
/// بخش فاز - برای ذخیره تخصیص کاربر و مهارت در سطح Phase
|
||||
@@ -1,8 +1,9 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
|
||||
/// <summary>
|
||||
/// فاز پروژه - سطح میانی در سلسله مراتب
|
||||
@@ -28,7 +29,7 @@ public class ProjectPhase : ProjectHierarchyNode
|
||||
}
|
||||
|
||||
public Guid ProjectId { get; private set; }
|
||||
public Project Project { get; private set; } = null!;
|
||||
public Project.Project Project { get; private set; } = null!;
|
||||
public IReadOnlyList<ProjectTask> Tasks => _tasks.AsReadOnly();
|
||||
public IReadOnlyList<PhaseSection> PhaseSections => _phaseSections.AsReadOnly();
|
||||
|
||||
@@ -41,15 +42,7 @@ public class ProjectPhase : ProjectHierarchyNode
|
||||
public ProjectDeployStatus DeployStatus { get; set; }
|
||||
|
||||
#region Task Management
|
||||
|
||||
public ProjectTask AddTask(string name, string? description = null)
|
||||
{
|
||||
var task = new ProjectTask(name, Id, description);
|
||||
_tasks.Add(task);
|
||||
AddDomainEvent(new TaskAddedEvent(task.Id, Id, name));
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
public void RemoveTask(Guid taskId)
|
||||
{
|
||||
var task = _tasks.FirstOrDefault(t => t.Id == taskId);
|
||||
@@ -1,8 +1,8 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
|
||||
/// <summary>
|
||||
/// پروژه - بالاترین سطح در سلسله مراتب و Aggregate Root
|
||||
@@ -1,7 +1,7 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
|
||||
/// <summary>
|
||||
/// ProjectSection: shortcut container for UserId + SkillId at Project level
|
||||
@@ -1,32 +1,34 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
||||
|
||||
/// <summary>
|
||||
/// تسک - پایینترین سطح در سلسله مراتب که شامل بخشها میشود
|
||||
/// </summary>
|
||||
public class ProjectTask : ProjectHierarchyNode
|
||||
{
|
||||
private readonly List<TaskSection> _sections;
|
||||
private readonly List<TaskSection.TaskSection> _sections;
|
||||
|
||||
private ProjectTask()
|
||||
{
|
||||
_sections = new List<TaskSection>();
|
||||
_sections = new List<TaskSection.TaskSection>();
|
||||
}
|
||||
|
||||
public ProjectTask(string name, Guid phaseId, string? description = null) : base(name, description)
|
||||
public ProjectTask(string name, Guid phaseId,ProjectTaskPriority priority, string? description = null) : base(name, description)
|
||||
{
|
||||
PhaseId = phaseId;
|
||||
_sections = new List<TaskSection>();
|
||||
Priority = ProjectTaskPriority.Low;
|
||||
_sections = new List<TaskSection.TaskSection>();
|
||||
BugSectionList = new List<BugSection>();
|
||||
Priority = priority;
|
||||
AddDomainEvent(new TaskCreatedEvent(Id, phaseId, name));
|
||||
}
|
||||
|
||||
public Guid PhaseId { get; private set; }
|
||||
public ProjectPhase Phase { get; private set; } = null!;
|
||||
public IReadOnlyList<TaskSection> Sections => _sections.AsReadOnly();
|
||||
public IReadOnlyList<TaskSection.TaskSection> Sections => _sections.AsReadOnly();
|
||||
public List<BugSection> BugSectionList { get; set; }
|
||||
|
||||
// Task-specific properties
|
||||
public Enums.TaskStatus Status { get; private set; } = Enums.TaskStatus.NotStarted;
|
||||
@@ -40,7 +42,7 @@ public class ProjectTask : ProjectHierarchyNode
|
||||
|
||||
#region Section Management
|
||||
|
||||
public void AddSection(TaskSection section, bool cascadeToChildren = false)
|
||||
public void AddSection(TaskSection.TaskSection section, bool cascadeToChildren = false)
|
||||
{
|
||||
var existingSection = _sections.FirstOrDefault(s => s.SkillId == section.SkillId);
|
||||
if (existingSection != null)
|
||||
@@ -84,7 +86,7 @@ public class ProjectTask : ProjectHierarchyNode
|
||||
return;
|
||||
}
|
||||
|
||||
var section = new TaskSection(Id, skillId, assignedUserId);
|
||||
var section = new TaskSection.TaskSection(Id, skillId, assignedUserId);
|
||||
_sections.Add(section);
|
||||
AddDomainEvent(new TaskSectionAddedEvent(Id, section.Id, skillId));
|
||||
}
|
||||
@@ -204,12 +206,12 @@ public class ProjectTask : ProjectHierarchyNode
|
||||
|
||||
#region Query Helpers
|
||||
|
||||
public IEnumerable<TaskSection> GetSectionsBySkill(Guid skillId)
|
||||
public IEnumerable<TaskSection.TaskSection> GetSectionsBySkill(Guid skillId)
|
||||
{
|
||||
return _sections.Where(s => s.SkillId == skillId);
|
||||
}
|
||||
|
||||
public TaskSection? GetSectionBySkill(Guid skillId)
|
||||
public TaskSection.TaskSection? GetSectionBySkill(Guid skillId)
|
||||
{
|
||||
return _sections.FirstOrDefault(s => s.SkillId == skillId);
|
||||
}
|
||||
@@ -219,7 +221,7 @@ public class ProjectTask : ProjectHierarchyNode
|
||||
return _sections.Any(s => s.SkillId == skillId);
|
||||
}
|
||||
|
||||
public IEnumerable<TaskSection> GetAssignedSections(long userId)
|
||||
public IEnumerable<TaskSection.TaskSection> GetAssignedSections(long userId)
|
||||
{
|
||||
return _sections.Where(s => s.CurrentAssignedUserId == userId);
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
using System.Linq;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Models;
|
||||
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
/// <summary>
|
||||
/// بخش تسک - برای ذخیره کار واقعی که کاربر روی یک مهارت خاص انجام میدهد
|
||||
@@ -61,12 +59,13 @@ public class TaskSection : EntityBase<Guid>
|
||||
// برای backward compatibility
|
||||
public TimeSpan EstimatedHours => FinalEstimatedHours;
|
||||
|
||||
public void AddAdditionalTime(TimeSpan additionalHours, string? reason = null, long? addedByUserId = null)
|
||||
public void AddAdditionalTime(TimeSpan additionalHours, TaskSectionAdditionalTimeType type, string? reason = null,
|
||||
long? addedByUserId = null)
|
||||
{
|
||||
if (additionalHours <= TimeSpan.Zero)
|
||||
throw new BadRequestException("تایم اضافی باید بزرگتر از صفر باشد", nameof(additionalHours));
|
||||
|
||||
var additionalTime = new TaskSectionAdditionalTime(additionalHours, reason, addedByUserId);
|
||||
var additionalTime = new TaskSectionAdditionalTime(additionalHours,type, reason, addedByUserId);
|
||||
_additionalTimes.Add(additionalTime);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
/// <summary>
|
||||
/// فعالیت کاری روی یک بخش
|
||||
@@ -1,6 +1,6 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
/// <summary>
|
||||
/// زمان اضافی اضافه شده بعد از تخمین اولیه
|
||||
@@ -9,12 +9,13 @@ public class TaskSectionAdditionalTime : EntityBase<Guid>
|
||||
{
|
||||
private TaskSectionAdditionalTime() { }
|
||||
|
||||
public TaskSectionAdditionalTime(TimeSpan hours, string? reason = null, long? addedByUserId = null)
|
||||
public TaskSectionAdditionalTime(TimeSpan hours, TaskSectionAdditionalTimeType type, string? reason = null,long? addedByUserId = null)
|
||||
{
|
||||
Hours = hours;
|
||||
Reason = reason;
|
||||
AddedByUserId = addedByUserId;
|
||||
AddedAt = DateTime.UtcNow;
|
||||
AddedAt = DateTime.Now;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public TimeSpan Hours { get; private set; }
|
||||
@@ -22,8 +23,15 @@ public class TaskSectionAdditionalTime : EntityBase<Guid>
|
||||
public long? AddedByUserId { get; private set; }
|
||||
public DateTime AddedAt { get; private set; }
|
||||
|
||||
public TaskSectionAdditionalTimeType Type { get; set; }
|
||||
public void UpdateReason(string? reason)
|
||||
{
|
||||
Reason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
public enum TaskSectionAdditionalTimeType
|
||||
{
|
||||
Effective,
|
||||
Ineffective,
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
public class TaskSectionRevision : EntityBase<Guid>
|
||||
{
|
||||
public TaskSectionRevision(Guid taskSectionId,
|
||||
string message, long createdByUserId)
|
||||
{
|
||||
TaskSectionId = taskSectionId;
|
||||
Status = RevisionReviewStatus.Pending;
|
||||
Message = message;
|
||||
CreatedByUserId = createdByUserId;
|
||||
}
|
||||
|
||||
public Guid TaskSectionId { get; private set; }
|
||||
|
||||
public RevisionReviewStatus Status { get; private set; }
|
||||
|
||||
|
||||
public string Message { get; private set; }
|
||||
|
||||
public long CreatedByUserId { get; private set; }
|
||||
|
||||
public IReadOnlyCollection<TaskRevisionFile> Files => _files;
|
||||
private readonly List<TaskRevisionFile> _files = new();
|
||||
|
||||
public void AddFile(TaskRevisionFile file)
|
||||
{
|
||||
_files.Add(file);
|
||||
}
|
||||
|
||||
public void MarkReviewed()
|
||||
{
|
||||
if (Status == RevisionReviewStatus.Reviewed)
|
||||
return;
|
||||
Status = RevisionReviewStatus.Reviewed;
|
||||
}
|
||||
|
||||
}
|
||||
public class TaskRevisionFile: EntityBase<Guid>
|
||||
{
|
||||
public TaskRevisionFile(Guid fileId)
|
||||
{
|
||||
FileId = fileId;
|
||||
}
|
||||
|
||||
public Guid FileId { get; private set; }
|
||||
}
|
||||
|
||||
public enum RevisionReviewStatus : short
|
||||
{
|
||||
Pending = 1,
|
||||
Reviewed = 2
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
public class TaskSectionTimeRequest:EntityBase<Guid>
|
||||
{
|
||||
|
||||
public TaskSectionTimeRequest(long userId, string description,
|
||||
TimeSpan requestedTime, TaskSectionTimeRequestType requestType,
|
||||
Guid taskSectionId)
|
||||
{
|
||||
UserId = userId;
|
||||
Description = description;
|
||||
RequestedTime = requestedTime;
|
||||
RequestType = requestType;
|
||||
TaskSectionId = taskSectionId;
|
||||
RequestStatus = TaskSectionTimeRequestStatus.Pending;
|
||||
}
|
||||
|
||||
public TaskSection TaskSection { get; set; }
|
||||
public Guid TaskSectionId { get; set; }
|
||||
public long UserId { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public TimeSpan RequestedTime { get; private set; }
|
||||
public TaskSectionTimeRequestType RequestType { get; private set; }
|
||||
public TaskSectionTimeRequestStatus RequestStatus { get; private set; }
|
||||
|
||||
public void AcceptTimeRequest()
|
||||
{
|
||||
RequestStatus = TaskSectionTimeRequestStatus.Accepted;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
|
||||
public enum TaskSectionTimeRequestStatus
|
||||
{
|
||||
Pending,
|
||||
Accepted,
|
||||
Rejected
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
|
||||
public enum TaskSectionTimeRequestType
|
||||
{
|
||||
InitialTime,
|
||||
AdditionalTime,
|
||||
RejectedTime,
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
public interface IBugSectionRepository : IRepository<Guid,BugSection>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
public interface IPhaseSectionRepository : IRepository<Guid, PhaseSection>
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
public interface ITaskSectionRevisionRepository:IRepository<Guid,TaskSectionRevision>
|
||||
{
|
||||
Task<List<TaskSectionRevision>> GetByTaskSectionId(Guid requestTaskSectionId);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
public interface ITaskSectionTimeRequestRepository:IRepository<Guid,TaskSectionTimeRequest>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
||||
|
||||
namespace GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
public class UnAuthorizedException:Exception
|
||||
{
|
||||
public UnAuthorizedException(string message) : base(message)
|
||||
public UnAuthorizedException(string message="احراز هویت شما منقضی شده است. لطفا دوباره وارد شوید") : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,3 @@
|
||||
|
||||
|
||||
|
||||
using FluentValidation;
|
||||
using GozareshgirProgramManager.Application._Common.Behaviors;
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application.Services.FileManagement;
|
||||
@@ -11,10 +7,7 @@ using GozareshgirProgramManager.Domain.CustomerAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.RoleAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.RoleAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.UserAgg.Repositories;
|
||||
@@ -32,6 +25,9 @@ using Shared.Contracts.PmRole.Commands;
|
||||
using Shared.Contracts.PmRole.Queries;
|
||||
using Shared.Contracts.PmUser.Commands;
|
||||
using Shared.Contracts.PmUser.Queries;
|
||||
using System.Reflection;
|
||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
||||
|
||||
namespace GozareshgirProgramManager.Infrastructure;
|
||||
|
||||
@@ -80,7 +76,8 @@ public static class DependencyInjection
|
||||
services.AddScoped<ITaskSectionActivityRepository, TaskSectionActivityRepository>();
|
||||
services.AddScoped<IPhaseSectionRepository, PhaseSectionRepository>();
|
||||
services.AddScoped<IProjectSectionRepository, ProjectSectionRepository>();
|
||||
|
||||
services.AddScoped<IBugSectionRepository, BugSectionRepository>();
|
||||
|
||||
services.AddScoped<ISkillRepository, SkillRepository>();
|
||||
|
||||
services.AddScoped<IUserRefreshTokenRepository, UserRefreshTokenRepository>();
|
||||
@@ -92,6 +89,7 @@ public static class DependencyInjection
|
||||
// File Storage Services
|
||||
services.AddScoped<IFileStorageService, Services.FileManagement.LocalFileStorageService>();
|
||||
services.AddScoped<IThumbnailGeneratorService, Services.FileManagement.ThumbnailGeneratorService>();
|
||||
services.AddScoped<IFileUploadService, Services.FileManagement.FileUploadService>();
|
||||
|
||||
// JWT Settings
|
||||
services.Configure<JwtSettings>(configuration.GetSection("JwtSettings"));
|
||||
@@ -100,7 +98,12 @@ public static class DependencyInjection
|
||||
services.AddScoped<JwtTokenGenerator>();
|
||||
services.AddScoped<IAuthHelper, AuthHelper>();
|
||||
|
||||
|
||||
//TaskSection Time Request
|
||||
services.AddScoped<ITaskSectionTimeRequestRepository, TaskSectionTimeRequestRepository>();
|
||||
|
||||
//TaskSection Revision
|
||||
services.AddScoped<ITaskSectionRevisionRepository, TaskSectionRevisionRepository>();
|
||||
|
||||
#region ServicesInjection
|
||||
|
||||
@@ -116,6 +119,16 @@ public static class DependencyInjection
|
||||
// MediatR Validation Behavior
|
||||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
|
||||
|
||||
// Workflow providers: auto-register all IWorkflowProvider implementations in the Application assembly
|
||||
var appAssembly = typeof(IWorkflowProvider).Assembly;
|
||||
var providerTypes = appAssembly
|
||||
.GetTypes()
|
||||
.Where(t => !t.IsAbstract && !t.IsInterface && typeof(IWorkflowProvider).IsAssignableFrom(t))
|
||||
.ToList();
|
||||
foreach (var providerType in providerTypes)
|
||||
{
|
||||
services.AddScoped(typeof(IWorkflowProvider), providerType);
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace GozareshgirProgramManager.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddtimeRequestandTasksectionrevision : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Type",
|
||||
table: "TaskSectionAdditionalTimes",
|
||||
type: "nvarchar(50)",
|
||||
maxLength: 50,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "TaskSectionRevisions",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
TaskSectionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
Message = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
|
||||
CreatedByUserId = table.Column<long>(type: "bigint", nullable: false),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_TaskSectionRevisions", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "TaskSectionTimeRequests",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
TaskSectionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
UserId = table.Column<long>(type: "bigint", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(1200)", maxLength: 1200, nullable: false),
|
||||
RequestedTime = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
|
||||
RequestType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
RequestStatus = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_TaskSectionTimeRequests", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_TaskSectionTimeRequests_TaskSections_TaskSectionId",
|
||||
column: x => x.TaskSectionId,
|
||||
principalTable: "TaskSections",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "TaskRevisionFile",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
FileId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
TaskSectionRevisionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_TaskRevisionFile", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_TaskRevisionFile_TaskSectionRevisions_TaskSectionRevisionId",
|
||||
column: x => x.TaskSectionRevisionId,
|
||||
principalTable: "TaskSectionRevisions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_TaskRevisionFile_UploadedFiles_FileId",
|
||||
column: x => x.FileId,
|
||||
principalTable: "UploadedFiles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TaskRevisionFile_FileId",
|
||||
table: "TaskRevisionFile",
|
||||
column: "FileId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TaskRevisionFile_TaskSectionRevisionId",
|
||||
table: "TaskRevisionFile",
|
||||
column: "TaskSectionRevisionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TaskSectionTimeRequests_TaskSectionId",
|
||||
table: "TaskSectionTimeRequests",
|
||||
column: "TaskSectionId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "TaskRevisionFile");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "TaskSectionTimeRequests");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "TaskSectionRevisions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Type",
|
||||
table: "TaskSectionAdditionalTimes");
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user