pm GetHolidaysInDates completed - remove OldholidayItems

This commit is contained in:
SamSys
2025-12-15 14:01:42 +03:30
parent a4f3feba1c
commit 1c1c8816a5
7 changed files with 27 additions and 106 deletions

View File

@@ -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<List<HolidayDto>> GetHolidaysInDates(DateTime startDate, DateTime endDate)
private readonly CompanyContext _context;
public HolidayQueryService(CompanyContext context)
{
throw new NotImplementedException();
_context = context;
}
public async Task<List<HolidayDto>> 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();
}
}

View File

@@ -185,7 +185,7 @@ public class CreateOrEditCheckoutCommandHandler : IBaseCommandHandler<CreateOrEd
var endMonth = Convert.ToInt32(endDate.Substring(5, 2));
var endDay = Convert.ToInt32(endDate.Substring(8, 2));
var persianEnd = new PersianDateTime(endYear, endMonth, endDay);
var holidays = await _holidayQueryService.GetHolidaysInDates(start, end) ;
var holidays = await _holidayQueryService.GetHolidaysInDates(start, end);
int mandatoryHours = 0;
for (var currentDay = persianStart; currentDay <= persianEnd; currentDay = currentDay.AddDays(1))
{
@@ -205,13 +205,9 @@ public class CreateOrEditCheckoutCommandHandler : IBaseCommandHandler<CreateOrEd
Console.WriteLine((int)getDaySetting.ShiftDuration.TotalMinutes + " " + currentDay + " - " + day);
}
}
}
//حقوق نهایی
var monthlySalaryPay = (totalHoursWorked * monthlySalaryDefined) / mandatoryHours;

View File

@@ -1,25 +0,0 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.HolidayItemAgg;
namespace GozareshgirProgramManager.Domain.HolidayAgg;
public class Holiday : EntityBase<long>
{
public Holiday(string year)
{
Year = year;
}
public string Year { get; private set; }
public List<HolidayItem> HolidayItems { get; set; }
public Holiday()
{
HolidayItems = new List<HolidayItem>();
}
public void Edit(string year)
{
Year = year;
}
}

View File

@@ -1,28 +0,0 @@
using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.HolidayAgg;
namespace GozareshgirProgramManager.Domain.HolidayItemAgg;
public class HolidayItem : EntityBase<long>
{
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;
}
}

View File

@@ -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<HolidayItem>
{
public void Configure(EntityTypeBuilder<HolidayItem> 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);
}
}

View File

@@ -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<Holiday>
{
public void Configure(EntityTypeBuilder<Holiday> 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);
}
}

View File

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