Compare commits

..

29 Commits

Author SHA1 Message Date
3a6e115f73 init 2026-01-29 11:29:03 +03:30
a55492b16a add CancelSendVerificationSms flag to InstitutionContractExtensionCompleteRequest and update SMS sending logic 2026-01-27 17:43:05 +03:30
9596c8f8b6 refactor FileUploadService to simplify category folder naming 2026-01-27 16:24:34 +03:30
8622f12f12 add file upload service and integrate with message sending 2026-01-27 15:54:38 +03:30
a20a847065 add mahan user for static accounts 2026-01-27 15:37:02 +03:30
258a809451 add .env files to .gitignore 2026-01-27 15:10:18 +03:30
gozareshgir
6285c7320e New PermissionCode to ProgramManager 2026-01-27 14:05:20 +03:30
9bca1b81d6 Merge remote-tracking branch 'origin/master' 2026-01-26 18:08:51 +03:30
9ff6b5cf56 fix rollcall mannaul edit bug 2026-01-26 18:08:33 +03:30
gozareshgir
04642b7257 Merge branch 'master' into Fix/program-manager/fix-some-bugs 2026-01-25 20:05:30 +03:30
c1c9fe51cb fix creation for institutioncontract on Not Authorized contracting party 2026-01-25 19:08:13 +03:30
gozareshgir
0d2ac58bbb change 2026-01-25 12:52:25 +03:30
43ccb3a1dd Merge remote-tracking branch 'origin/master' 2026-01-24 19:10:59 +03:30
0134111aba fix bug for extensions 2026-01-24 19:10:24 +03:30
gozareshgir
3cc7adae35 Merge branch 'Feature/CheckoutReward' 2026-01-24 18:58:24 +03:30
gozareshgir
c97ea5356f Add Reward To checkout Completed 2026-01-24 18:57:53 +03:30
69f4819bf6 Add Migration For Reward checkout 2026-01-24 16:58:45 +03:30
gozareshgir
1257e15b62 changeMapping 2026-01-24 16:45:10 +03:30
gozareshgir
331fb24a99 CheckoutReward 2026-01-24 16:29:01 +03:30
3be1547137 fix mannually verify error 2026-01-24 16:25:22 +03:30
900b4b3f4d add convention for print InstitutionContract for pending data 2026-01-22 12:58:43 +03:30
bdc6f95af8 fix activate all after create new 2026-01-22 12:26:13 +03:30
7a73e69afa Merge branch 'master' into Fix/program-manager/fix-some-bugs 2026-01-22 11:06:58 +03:30
gozareshgir
21302803b6 insurance WorkingDays bug Fixed 2026-01-19 12:32:51 +03:30
b7172630e2 set orders for projects 2026-01-13 15:49:51 +03:30
0604514190 Merge branch 'refs/heads/master' into Fix/program-manager/fix-some-bugs 2026-01-13 14:51:25 +03:30
ff5180eb75 remove add task to phase 2026-01-12 17:39:54 +03:30
a1c9335487 add remaining time and spent time to get project list 2026-01-12 16:48:54 +03:30
20ece4886c add task priority to CreateProjectCommand 2026-01-12 12:20:08 +03:30
132 changed files with 12939 additions and 3172 deletions

3
.gitignore vendored
View File

@@ -368,3 +368,6 @@ MigrationBackup/
# Storage folder - ignore all uploaded files, thumbnails, and temporary files
ServiceHost/Storage
.env
.env.*

View File

@@ -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>
/// این تاریخ در جدول اکانت لفت ورک به این معنیست

View File

@@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<NuGetAudit>false</NuGetAudit>
</PropertyGroup>
<ItemGroup>

View File

@@ -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;

View 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; }
}

View File

@@ -66,4 +66,9 @@ public class File1 : EntityBase
Description = description;
Status = status;
}
public void ChangeStatus(int status)
{
Status = status;
}
}

View File

@@ -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);
}

View File

@@ -531,6 +531,11 @@ namespace Company.Domain.RollCallAgg
FridayWorkTimeSpan = CalculateFridayWorkDuration(StartDate.Value, EndDate.Value);
}
public void SetStartDate(DateTime start)
{
StartDate = start;
}
/// <summary>
/// جیزه
/// </summary>

View File

@@ -15,11 +15,12 @@ public interface ISalaryAidRepository:IRepository<long,SalaryAid>
void RemoveRange(IEnumerable<SalaryAid> salaryAids);
#region Pooya
/// <summary>
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
/// </summary>
SalaryAidsGroupedViewModel GetSearchListAsGrouped(SalaryAidSearchViewModel searchModel);
SalaryAidsGroupedViewModel GetSearchListAsGrouped(SalaryAidSearchViewModel searchModel);
#endregion
}

View File

@@ -193,4 +193,9 @@ public class CreateCheckout
/// پایه سنوات قبل از تاثیر ساعت کار
/// </summary>
public double BaseYearUnAffected { get; set; }
/// <summary>
/// آیا برای محاسبه پاداش مجاز است
/// </summary>
public bool RewardPayCompute { get; set; }
}

View File

@@ -4,6 +4,7 @@
<TargetFramework>net10.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
<NuGetAudit>false</NuGetAudit>
</PropertyGroup>
<ItemGroup>

View File

@@ -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

View File

@@ -7,6 +7,7 @@ public class InstitutionContractExtensionCompleteRequest
public Guid TemporaryId { get; set; }
public bool IsInstallment { get; set; }
public long LawId { get; set; }
public bool CancelSendVerificationSms { get; set; }
}
public class InstitutionContractCreationCompleteRequest

View File

@@ -151,6 +151,9 @@ public class CreateWorkshop
/// تصفیه حساب بصورت استاتیک محاصبه شود
/// </summary>
public bool IsStaticCheckout { get; set; }
/// <summary>
/// آیا پاداش در فیش حقوقی محاسبه شود
/// </summary>
public bool RewardComputeOnCheckout { get; set; }
}

View File

@@ -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();

View File

@@ -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();
}

View File

@@ -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,

View File

@@ -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);

View File

@@ -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();

File diff suppressed because it is too large Load Diff

View File

@@ -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");
}
}
}

View File

@@ -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");

View File

@@ -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,

View File

@@ -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,8 @@ 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 +2278,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 +2318,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)
@@ -2958,8 +2960,11 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
await SaveChangesAsync();
await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName,
entity.PublicId, contractingParty.id, entity.id);
if (!request.CancelSendVerificationSms)
{
await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName,
entity.PublicId, contractingParty.id, entity.id);
}
await SaveChangesAsync();
@@ -3358,9 +3363,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 +3576,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
#endregion
#region PrivateMetods
/// <summary>
@@ -3611,11 +3620,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
#endregion
//ایجاد سند مالی ماهانه
#region CreateMontlyTransaction
/// <summary>
@@ -3625,7 +3631,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 +3661,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 +3708,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 +4013,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
}
public async Task<long> GetIdByInstallmentId(long installmentId)
{
return await _context.InstitutionContractSet.Include(x => x.Installments)
@@ -4364,10 +4367,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 +4449,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
Id = 0,
IdNumberSerial = "",
IdNumberSeri = "",
};
creationTemp.SetContractingPartyInfo(request.LegalType, real, legal);
}
@@ -4462,7 +4465,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;
}
@@ -5109,9 +5113,11 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
await SaveChangesAsync();
await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName,
entity.PublicId, contractingParty.id, entity.id);
if (!request.CancelSendVerificationSms)
{
await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName,
entity.PublicId, contractingParty.id, entity.id);
}
await SaveChangesAsync();
await transaction.CommitAsync();
@@ -5221,11 +5227,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
#endregion
#region CustomViewModels
public class WorkshopsAndEmployeeViewModel

View File

@@ -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;

View File

@@ -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);

View File

@@ -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,

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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}");
}
}
}

View File

@@ -2,9 +2,6 @@ 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;

View File

@@ -2,7 +2,6 @@ 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;

View File

@@ -2,7 +2,6 @@ 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;

View File

@@ -1,8 +1,6 @@
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;
@@ -71,7 +69,7 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPr
if (phase is null)
return OperationResult.NotFound("فاز یافت نشد");
var tasks = phase.Tasks?.ToList() ?? new List<ProjectTask>();
var tasks = phase.Tasks?.ToList() ?? new List<Domain.ProjectAgg.Entities.ProjectTask>();
foreach (var t in tasks)
{
if (t.Priority != priority)
@@ -91,10 +89,10 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPr
if (project is null)
return OperationResult.NotFound("پروژه یافت نشد");
var phases = project.Phases?.ToList() ?? new List<ProjectPhase>();
var phases = project.Phases?.ToList() ?? new List<Domain.ProjectAgg.Entities.ProjectPhase>();
foreach (var phase in phases)
{
var tasks = phase.Tasks?.ToList() ?? new List<ProjectTask>();
var tasks = phase.Tasks?.ToList() ?? new List<Domain.ProjectAgg.Entities.ProjectTask>();
foreach (var t in tasks)
{
if (t.Priority != priority)

View File

@@ -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;

View File

@@ -3,9 +3,6 @@ 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;
@@ -19,7 +16,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;
@@ -58,8 +56,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("والد پروژه یافت نشد");
}
@@ -72,14 +70,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);
}
}
}

View File

@@ -2,7 +2,6 @@ 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;

View File

@@ -1,7 +1,5 @@
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;
@@ -17,5 +15,4 @@ public class SetTimeSectionTime
public string Description { get; set; }
public int Hours { get; set; }
public int Minutes { get; set; }
public TaskSectionAdditionalTimeType Type { get; set; }
}

View File

@@ -4,9 +4,6 @@ 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;
@@ -372,7 +369,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.Type, additionalTime.Description, addedByUserId);
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
hasAdditionalTime = true;
}

View File

@@ -1,9 +1,5 @@
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;

View File

@@ -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; }

View File

@@ -4,10 +4,6 @@ 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;
@@ -20,7 +16,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>();
@@ -55,13 +52,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,
@@ -69,10 +67,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;
}
@@ -83,13 +83,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,
@@ -97,10 +98,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;
}
@@ -111,6 +114,7 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
{
query = query.Where(x => x.PhaseId == parentId);
}
var entities = await query
.OrderByDescending(t => t.CreationDate)
.ToListAsync(cancellationToken);
@@ -122,7 +126,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)
@@ -144,13 +148,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 برمی‌گردانیم
@@ -188,18 +191,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;
@@ -217,7 +222,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
@@ -247,7 +253,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
@@ -273,68 +280,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)
@@ -345,7 +365,7 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
// بررسی وجود user
bool hasUser = section.CurrentAssignedUserId > 0;
// بررسی وجود time (InitialEstimatedHours بزرگتر از صفر باشد)
bool hasTime = section.InitialEstimatedHours > TimeSpan.Zero;
@@ -360,5 +380,4 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
// تعیین تکلیف نشده: نه user دارد نه time
return AssignmentStatus.Unassigned;
}
}
}

View File

@@ -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; }

View File

@@ -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; }
}

View File

@@ -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 کردن نتیجه

View File

@@ -3,7 +3,6 @@ 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;

View File

@@ -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;
}
}
}

View File

@@ -1,7 +1,6 @@
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;
@@ -29,7 +28,7 @@ public class GetMessagesQueryHandler : IBaseQueryHandler<GetMessagesQuery, Pagin
}
private List<MessageDto> CreateAdditionalTimeNotes(
IEnumerable<TaskSectionAdditionalTime> additionalTimes,
IEnumerable<Domain.ProjectAgg.Entities.TaskSectionAdditionalTime> additionalTimes,
Dictionary<long, string> users,
Guid taskId)
{

View File

@@ -1,136 +0,0 @@
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;
}
}

View File

@@ -1,14 +0,0 @@
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("توضیحات اجباری است");
}
}

View File

@@ -1,35 +0,0 @@
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();
}
}

View File

@@ -1,92 +0,0 @@
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);
}
}

View File

@@ -1,16 +0,0 @@
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;

View File

@@ -1,56 +0,0 @@
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();
}
}

View File

@@ -1,24 +0,0 @@
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 باشد");
}
}

View File

@@ -1,52 +0,0 @@
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();
}
}

View File

@@ -1,20 +0,0 @@
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();
}
}

View File

@@ -1,66 +0,0 @@
using GozareshgirProgramManager.Application._Common.Extensions;
using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Application._Common.Models;
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain._Common.Exceptions;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
using Microsoft.EntityFrameworkCore;
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Queries.CreateTimeRequestDetails;
public record CreateTimeRequestDetailsResponse(List<CreateTimeRequestDetailsRevision> Revisions,
string ProjectName,string PhaseName,string SectionName,string SkillName);
public record CreateTimeRequestDetailsRevision(string Message, List<UploadedFileDto> Files,Guid Id,string CreationDate);
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 section =await _context.TaskSections
.Include(x => x.Task)
.ThenInclude(x => x.Phase)
.ThenInclude(x => x.Project)
.Include(x => x.Skill)
.FirstOrDefaultAsync(x => x.Id == request.TaskSectionId, cancellationToken: cancellationToken);
if (section == null)
{
throw new BadRequestException("بخش فرعی نامعتبر است");
}
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.FileId).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,x.Id,x.CreationDate.ToFarsi());
}).ToList();
var res = new CreateTimeRequestDetailsResponse(resItem,section.Task.Phase.Project.Name,section.Task.Phase.Name,section.Task.Name,
section.Skill!.Name);
return OperationResult<CreateTimeRequestDetailsResponse>.Success(res);
}
}

View File

@@ -1,11 +0,0 @@
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);
}

View File

@@ -1,31 +0,0 @@
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);
}
}

View File

@@ -1,41 +0,0 @@
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);
}
}

View File

@@ -1,50 +0,0 @@
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);
}
}

View File

@@ -1,56 +0,0 @@
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,
}
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>();
foreach (var provider in _providers)
{
var providerItems = await provider.GetItems(currentUserId, _context, cancellationToken);
if (providerItems?.Count > 0)
items.AddRange(providerItems);
}
var res = new WorkflowListResponse(items);
return OperationResult<WorkflowListResponse>.Success(res);
}
}

View File

@@ -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
};
}
}

View File

@@ -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>();

View File

@@ -1,23 +0,0 @@
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
};
}
}

View File

@@ -9,10 +9,6 @@ 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;
@@ -35,12 +31,6 @@ public interface IProgramManagerDbContext
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);
}

View File

@@ -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);

View File

@@ -1,34 +0,0 @@
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";
}
}
}

View File

@@ -10,7 +10,6 @@ public enum FileCategory
ProjectDocument = 3, // مستندات پروژه
UserProfilePhoto = 4, // عکس پروفایل کاربر
Report = 5, // گزارش
Other = 6, // سایر
TaskSectionRevision
Other = 6 // سایر
}

View File

@@ -1,7 +1,7 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
/// <summary>
/// بخش فاز - برای ذخیره تخصیص کاربر و مهارت در سطح Phase

View File

@@ -1,8 +1,8 @@
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
/// <summary>
/// پروژه - بالاترین سطح در سلسله مراتب و Aggregate Root

View File

@@ -1,9 +1,8 @@
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
/// <summary>
/// فاز پروژه - سطح میانی در سلسله مراتب
@@ -29,7 +28,7 @@ public class ProjectPhase : ProjectHierarchyNode
}
public Guid ProjectId { get; private set; }
public Project.Project Project { get; private set; } = null!;
public Project Project { get; private set; } = null!;
public IReadOnlyList<ProjectTask> Tasks => _tasks.AsReadOnly();
public IReadOnlyList<PhaseSection> PhaseSections => _phaseSections.AsReadOnly();
@@ -42,15 +41,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);

View File

@@ -1,7 +1,7 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
/// <summary>
/// ProjectSection: shortcut container for UserId + SkillId at Project level

View File

@@ -1,32 +1,32 @@
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
/// <summary>
/// تسک - پایین‌ترین سطح در سلسله مراتب که شامل بخش‌ها می‌شود
/// </summary>
public class ProjectTask : ProjectHierarchyNode
{
private readonly List<TaskSection.TaskSection> _sections;
private readonly List<TaskSection> _sections;
private ProjectTask()
{
_sections = new List<TaskSection.TaskSection>();
_sections = new List<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.TaskSection>();
Priority = ProjectTaskPriority.Low;
_sections = new List<TaskSection>();
Priority = priority;
AddDomainEvent(new TaskCreatedEvent(Id, phaseId, name));
}
public Guid PhaseId { get; private set; }
public ProjectPhase Phase { get; private set; } = null!;
public IReadOnlyList<TaskSection.TaskSection> Sections => _sections.AsReadOnly();
public IReadOnlyList<TaskSection> Sections => _sections.AsReadOnly();
// Task-specific properties
public Enums.TaskStatus Status { get; private set; } = Enums.TaskStatus.NotStarted;
@@ -40,7 +40,7 @@ public class ProjectTask : ProjectHierarchyNode
#region Section Management
public void AddSection(TaskSection.TaskSection section, bool cascadeToChildren = false)
public void AddSection(TaskSection section, bool cascadeToChildren = false)
{
var existingSection = _sections.FirstOrDefault(s => s.SkillId == section.SkillId);
if (existingSection != null)
@@ -84,7 +84,7 @@ public class ProjectTask : ProjectHierarchyNode
return;
}
var section = new TaskSection.TaskSection(Id, skillId, assignedUserId);
var section = new TaskSection(Id, skillId, assignedUserId);
_sections.Add(section);
AddDomainEvent(new TaskSectionAddedEvent(Id, section.Id, skillId));
}
@@ -204,12 +204,12 @@ public class ProjectTask : ProjectHierarchyNode
#region Query Helpers
public IEnumerable<TaskSection.TaskSection> GetSectionsBySkill(Guid skillId)
public IEnumerable<TaskSection> GetSectionsBySkill(Guid skillId)
{
return _sections.Where(s => s.SkillId == skillId);
}
public TaskSection.TaskSection? GetSectionBySkill(Guid skillId)
public TaskSection? GetSectionBySkill(Guid skillId)
{
return _sections.FirstOrDefault(s => s.SkillId == skillId);
}
@@ -219,7 +219,7 @@ public class ProjectTask : ProjectHierarchyNode
return _sections.Any(s => s.SkillId == skillId);
}
public IEnumerable<TaskSection.TaskSection> GetAssignedSections(long userId)
public IEnumerable<TaskSection> GetAssignedSections(long userId)
{
return _sections.Where(s => s.CurrentAssignedUserId == userId);
}

View File

@@ -1,56 +0,0 @@
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
}

View File

@@ -1,33 +0,0 @@
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;
}
}

View File

@@ -1,10 +1,12 @@
using GozareshgirProgramManager.Domain._Common;
using System.Linq;
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.Task.TaskSection;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
/// <summary>
/// بخش تسک - برای ذخیره کار واقعی که کاربر روی یک مهارت خاص انجام می‌دهد
@@ -59,13 +61,12 @@ public class TaskSection : EntityBase<Guid>
// برای backward compatibility
public TimeSpan EstimatedHours => FinalEstimatedHours;
public void AddAdditionalTime(TimeSpan additionalHours, TaskSectionAdditionalTimeType type, string? reason = null,
long? addedByUserId = null)
public void AddAdditionalTime(TimeSpan additionalHours, string? reason = null, long? addedByUserId = null)
{
if (additionalHours <= TimeSpan.Zero)
throw new BadRequestException("تایم اضافی باید بزرگتر از صفر باشد", nameof(additionalHours));
var additionalTime = new TaskSectionAdditionalTime(additionalHours,type, reason, addedByUserId);
var additionalTime = new TaskSectionAdditionalTime(additionalHours, reason, addedByUserId);
_additionalTimes.Add(additionalTime);
}

View File

@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using GozareshgirProgramManager.Domain._Common;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
/// <summary>
/// فعالیت کاری روی یک بخش

View File

@@ -1,6 +1,6 @@
using GozareshgirProgramManager.Domain._Common;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
/// <summary>
/// زمان اضافی اضافه شده بعد از تخمین اولیه
@@ -9,13 +9,12 @@ public class TaskSectionAdditionalTime : EntityBase<Guid>
{
private TaskSectionAdditionalTime() { }
public TaskSectionAdditionalTime(TimeSpan hours, TaskSectionAdditionalTimeType type, string? reason = null,long? addedByUserId = null)
public TaskSectionAdditionalTime(TimeSpan hours, string? reason = null, long? addedByUserId = null)
{
Hours = hours;
Reason = reason;
AddedByUserId = addedByUserId;
AddedAt = DateTime.Now;
Type = type;
AddedAt = DateTime.UtcNow;
}
public TimeSpan Hours { get; private set; }
@@ -23,15 +22,8 @@ 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,
}

View File

@@ -1,8 +0,0 @@
namespace GozareshgirProgramManager.Domain.ProjectAgg.Enums;
public enum TaskSectionTimeRequestStatus
{
Pending,
Accepted,
Rejected
}

View File

@@ -1,8 +0,0 @@
namespace GozareshgirProgramManager.Domain.ProjectAgg.Enums;
public enum TaskSectionTimeRequestType
{
InitialTime,
AdditionalTime,
RejectedTime,
}

View File

@@ -1,7 +1,5 @@
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>
{

View File

@@ -1,6 +1,5 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;

View File

@@ -1,6 +1,5 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;

View File

@@ -1,6 +1,5 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;

View File

@@ -1,6 +1,5 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;

View File

@@ -1,6 +1,5 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;

View File

@@ -1,7 +1,6 @@
using System.Collections;
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;

View File

@@ -1,9 +0,0 @@
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);
}

View File

@@ -1,10 +0,0 @@
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>
{
}

View File

@@ -1,6 +1,5 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
namespace GozareshgirProgramManager.Domain.SkillAgg.Entities;

View File

@@ -2,7 +2,7 @@
public class UnAuthorizedException:Exception
{
public UnAuthorizedException(string message="احراز هویت شما منقضی شده است. لطفا دوباره وارد شوید") : base(message)
public UnAuthorizedException(string message) : base(message)
{
}
}

View File

@@ -1,3 +1,7 @@
using FluentValidation;
using GozareshgirProgramManager.Application._Common.Behaviors;
using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Application.Services.FileManagement;
@@ -7,7 +11,10 @@ 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;
@@ -25,9 +32,6 @@ 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;
@@ -88,6 +92,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"));
@@ -96,12 +101,7 @@ 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
@@ -117,16 +117,6 @@ 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;
}

View File

@@ -1,121 +0,0 @@
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");
}
}
}

View File

@@ -227,7 +227,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.ToTable("UploadedFiles", (string)null);
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.PhaseSection", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.PhaseSection", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -254,7 +254,49 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.ToTable("PhaseSections");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<DateTime?>("EndDate")
.HasColumnType("datetime2");
b.Property<bool>("HasAssignmentOverride")
.HasColumnType("bit");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<DateTime?>("PlannedEndDate")
.HasColumnType("datetime2");
b.Property<DateTime?>("PlannedStartDate")
.HasColumnType("datetime2");
b.Property<DateTime?>("StartDate")
.HasColumnType("datetime2");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Projects", (string)null);
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectPhase", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
@@ -306,49 +348,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.ToTable("ProjectPhases", (string)null);
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<DateTime?>("EndDate")
.HasColumnType("datetime2");
b.Property<bool>("HasAssignmentOverride")
.HasColumnType("bit");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<DateTime?>("PlannedEndDate")
.HasColumnType("datetime2");
b.Property<DateTime?>("PlannedStartDate")
.HasColumnType("datetime2");
b.Property<DateTime?>("StartDate")
.HasColumnType("datetime2");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Projects", (string)null);
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.ProjectSection", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectSection", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
@@ -374,7 +374,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.ToTable("ProjectSections");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectTask", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
@@ -433,7 +433,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.ToTable("ProjectTasks", (string)null);
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
@@ -476,7 +476,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.ToTable("TaskSections", (string)null);
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionActivity", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSectionActivity", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
@@ -514,7 +514,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.ToTable("TaskSectionActivities", (string)null);
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionAdditionalTime", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSectionAdditionalTime", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
@@ -540,11 +540,6 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.Property<Guid?>("TaskSectionId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.HasIndex("TaskSectionId");
@@ -552,76 +547,6 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.ToTable("TaskSectionAdditionalTimes", (string)null);
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionRevision", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<long>("CreatedByUserId")
.HasColumnType("bigint");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<string>("Message")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<Guid>("TaskSectionId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.ToTable("TaskSectionRevisions");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionTimeRequest", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1200)
.HasColumnType("nvarchar(1200)");
b.Property<string>("RequestStatus")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("RequestType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("RequestedTime")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<Guid>("TaskSectionId")
.HasColumnType("uniqueidentifier");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("TaskSectionId");
b.ToTable("TaskSectionTimeRequests");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.RoleAgg.Entities.Role", b =>
{
b.Property<long>("Id")
@@ -867,9 +792,9 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.ToTable("UserRefreshTokens", (string)null);
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.PhaseSection", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.PhaseSection", b =>
{
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", "Phase")
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectPhase", "Phase")
.WithMany("PhaseSections")
.HasForeignKey("PhaseId")
.OnDelete(DeleteBehavior.Cascade)
@@ -885,9 +810,9 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.Navigation("Skill");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectPhase", b =>
{
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", "Project")
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project", "Project")
.WithMany("Phases")
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade)
@@ -896,9 +821,9 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.Navigation("Project");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.ProjectSection", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectSection", b =>
{
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", "Project")
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project", "Project")
.WithMany("ProjectSections")
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade)
@@ -914,9 +839,9 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.Navigation("Skill");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectTask", b =>
{
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", "Phase")
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectPhase", "Phase")
.WithMany("Tasks")
.HasForeignKey("PhaseId")
.OnDelete(DeleteBehavior.Cascade)
@@ -925,7 +850,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.Navigation("Phase");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", b =>
{
b.HasOne("GozareshgirProgramManager.Domain.SkillAgg.Entities.Skill", "Skill")
.WithMany("Sections")
@@ -933,7 +858,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", "Task")
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectTask", "Task")
.WithMany("Sections")
.HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Cascade)
@@ -944,9 +869,9 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.Navigation("Task");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionActivity", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSectionActivity", b =>
{
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", "Section")
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", "Section")
.WithMany("Activities")
.HasForeignKey("SectionId")
.OnDelete(DeleteBehavior.Cascade)
@@ -955,61 +880,13 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.Navigation("Section");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionAdditionalTime", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSectionAdditionalTime", b =>
{
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", null)
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", null)
.WithMany("AdditionalTimes")
.HasForeignKey("TaskSectionId");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionRevision", b =>
{
b.OwnsMany("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskRevisionFile", "Files", b1 =>
{
b1.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b1.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b1.Property<Guid>("FileId")
.HasColumnType("uniqueidentifier");
b1.Property<Guid>("TaskSectionRevisionId")
.HasColumnType("uniqueidentifier");
b1.HasKey("Id");
b1.HasIndex("FileId");
b1.HasIndex("TaskSectionRevisionId");
b1.ToTable("TaskRevisionFile");
b1.HasOne("GozareshgirProgramManager.Domain.FileManagementAgg.Entities.UploadedFile", null)
.WithMany()
.HasForeignKey("FileId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b1.WithOwner()
.HasForeignKey("TaskSectionRevisionId");
});
b.Navigation("Files");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionTimeRequest", b =>
{
b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", "TaskSection")
.WithMany()
.HasForeignKey("TaskSectionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("TaskSection");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.RoleAgg.Entities.Role", b =>
{
b.OwnsMany("GozareshgirProgramManager.Domain.PermissionAgg.Entities.Permission", "Permissions", b1 =>
@@ -1154,26 +1031,26 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations
b.Navigation("User");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", b =>
{
b.Navigation("PhaseSections");
b.Navigation("Tasks");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project", b =>
{
b.Navigation("Phases");
b.Navigation("ProjectSections");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectPhase", b =>
{
b.Navigation("PhaseSections");
b.Navigation("Tasks");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectTask", b =>
{
b.Navigation("Sections");
});
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", b =>
modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", b =>
{
b.Navigation("Activities");

View File

@@ -5,10 +5,6 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Domain.CustomerAgg;
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
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.RoleAgg.Entities;
using GozareshgirProgramManager.Domain.RoleUserAgg;
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Entities;
@@ -53,12 +49,6 @@ public class ProgramManagerDbContext : DbContext, IProgramManagerDbContext
// Task Chat
public DbSet<TaskChatMessage> TaskChatMessages { get; set; } = null!;
//Task Section Time Request
public DbSet<TaskSectionTimeRequest> TaskSectionTimeRequests { get; set; }
// Task Section Revision
public DbSet<TaskSectionRevision> TaskSectionRevisions { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(ProgramManagerDbContext).Assembly);

View File

@@ -1,5 +1,4 @@
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
using GozareshgirProgramManager.Infrastructure.Persistence._Common;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

View File

@@ -1,5 +1,4 @@
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

Some files were not shown because too many files have changed in this diff Show More