From 1c1c8816a51104a2fd242201ebb8132acf47e675 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 15 Dec 2025 14:01:42 +0330 Subject: [PATCH] pm GetHolidaysInDates completed - remove OldholidayItems --- .../Services/HolidayQueryService.cs | 28 +++++++++++++++---- .../CreateOrEditCheckoutCommandHandler.cs | 6 +--- .../HolidayAgg/Holiday.cs | 25 ----------------- .../HolidayItemAgg/HolidayItem.cs | 28 ------------------- .../Mappings/HolidayItemMapping.cs | 20 ------------- .../Persistence/Mappings/HolidayMapping.cs | 20 ------------- Shared.Contracts/Holidays/HolidayDto.cs | 6 ++-- 7 files changed, 27 insertions(+), 106 deletions(-) delete mode 100644 ProgramManager/src/Domain/GozareshgirProgramManager.Domain/HolidayAgg/Holiday.cs delete mode 100644 ProgramManager/src/Domain/GozareshgirProgramManager.Domain/HolidayItemAgg/HolidayItem.cs delete mode 100644 ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/HolidayItemMapping.cs delete mode 100644 ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/HolidayMapping.cs diff --git a/CompanyManagment.EFCore/Services/HolidayQueryService.cs b/CompanyManagment.EFCore/Services/HolidayQueryService.cs index 4b8aa51c..e8c2e4f3 100644 --- a/CompanyManagment.EFCore/Services/HolidayQueryService.cs +++ b/CompanyManagment.EFCore/Services/HolidayQueryService.cs @@ -1,14 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using PersianTools.Core; using Shared.Contracts.Holidays; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; namespace CompanyManagment.EFCore.Services; public class HolidayQueryService : IHolidayQueryService { - public Task> GetHolidaysInDates(DateTime startDate, DateTime endDate) + private readonly CompanyContext _context; + + public HolidayQueryService(CompanyContext context) { - throw new NotImplementedException(); + _context = context; + } + + public async Task> GetHolidaysInDates(DateTime startDate, DateTime endDate) + { + return await _context.HolidayItems.Where(x => x.Holidaydate >= startDate && x.Holidaydate <= endDate).Select(x=> new HolidayDto() + { + Holidaydate = x.Holidaydate, + HolidayId = x.id, + HolidayYear = x.HolidayYear + }) + .ToListAsync(); + } } \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Checkouts/Commands/CreateCheckout/CreateOrEditCheckoutCommandHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Checkouts/Commands/CreateCheckout/CreateOrEditCheckoutCommandHandler.cs index 3536ad0e..9b3fdcb8 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Checkouts/Commands/CreateCheckout/CreateOrEditCheckoutCommandHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Checkouts/Commands/CreateCheckout/CreateOrEditCheckoutCommandHandler.cs @@ -185,7 +185,7 @@ public class CreateOrEditCheckoutCommandHandler : IBaseCommandHandler -{ - public Holiday(string year) - { - Year = year; - - } - - public string Year { get; private set; } - public List HolidayItems { get; set; } - - public Holiday() - { - HolidayItems = new List(); - } - public void Edit(string year) - { - Year = year; - } -} \ No newline at end of file diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/HolidayItemAgg/HolidayItem.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/HolidayItemAgg/HolidayItem.cs deleted file mode 100644 index 3a66bd58..00000000 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/HolidayItemAgg/HolidayItem.cs +++ /dev/null @@ -1,28 +0,0 @@ -using GozareshgirProgramManager.Domain._Common; -using GozareshgirProgramManager.Domain.HolidayAgg; - -namespace GozareshgirProgramManager.Domain.HolidayItemAgg; - -public class HolidayItem : EntityBase -{ - public HolidayItem(DateTime holidaydate, long holidayId, string holidayYear) - { - Holidaydate = holidaydate; - HolidayId = holidayId; - HolidayYear = holidayYear; - } - - public DateTime Holidaydate { get; private set; } - public long HolidayId { get; private set; } - public string HolidayYear { get; private set; } - - public Holiday Holidayss { get; set; } - - public void Edit(DateTime holidaydate, long holidayId, string holidayYear) - { - Holidaydate = holidaydate; - HolidayId = holidayId; - HolidayYear = holidayYear; - - } -} \ No newline at end of file diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/HolidayItemMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/HolidayItemMapping.cs deleted file mode 100644 index 42eff124..00000000 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/HolidayItemMapping.cs +++ /dev/null @@ -1,20 +0,0 @@ -using GozareshgirProgramManager.Domain.HolidayItemAgg; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings; - -public class HolidayItemMapping : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable("Holidayitems"); - builder.HasKey(x => x.Id); - - builder.Property(x => x.HolidayYear).HasMaxLength(4); - - builder.HasOne(x => x.Holidayss) - .WithMany(x => x.HolidayItems) - .HasForeignKey(x => x.HolidayId); - } -} \ No newline at end of file diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/HolidayMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/HolidayMapping.cs deleted file mode 100644 index 3038d89a..00000000 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/HolidayMapping.cs +++ /dev/null @@ -1,20 +0,0 @@ -using GozareshgirProgramManager.Domain.HolidayAgg; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings; - -public class HolidayMapping : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable("Holidays"); - builder.HasKey(x => x.Id); - - builder.Property(x => x.Year).HasMaxLength(4); - - builder.HasMany(x => x.HolidayItems) - .WithOne(x => x.Holidayss) - .HasForeignKey(x => x.HolidayId); - } -} \ No newline at end of file diff --git a/Shared.Contracts/Holidays/HolidayDto.cs b/Shared.Contracts/Holidays/HolidayDto.cs index 7318b83e..107977ae 100644 --- a/Shared.Contracts/Holidays/HolidayDto.cs +++ b/Shared.Contracts/Holidays/HolidayDto.cs @@ -2,7 +2,7 @@ namespace Shared.Contracts.Holidays; public record HolidayDto { - public DateTime Holidaydate { get; private set; } - public long HolidayId { get; private set; } - public string HolidayYear { get; private set; } + public DateTime Holidaydate { get; set; } + public long HolidayId { get; set; } + public string HolidayYear { get; set; } } \ No newline at end of file