pm GetHolidaysInDates completed - remove OldholidayItems
This commit is contained in:
@@ -1,14 +1,32 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Collections.Generic;
|
using PersianTools.Core;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Shared.Contracts.Holidays;
|
using Shared.Contracts.Holidays;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CompanyManagment.EFCore.Services;
|
namespace CompanyManagment.EFCore.Services;
|
||||||
|
|
||||||
public class HolidayQueryService : IHolidayQueryService
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,7 @@ public class CreateOrEditCheckoutCommandHandler : IBaseCommandHandler<CreateOrEd
|
|||||||
var endMonth = Convert.ToInt32(endDate.Substring(5, 2));
|
var endMonth = Convert.ToInt32(endDate.Substring(5, 2));
|
||||||
var endDay = Convert.ToInt32(endDate.Substring(8, 2));
|
var endDay = Convert.ToInt32(endDate.Substring(8, 2));
|
||||||
var persianEnd = new PersianDateTime(endYear, endMonth, endDay);
|
var persianEnd = new PersianDateTime(endYear, endMonth, endDay);
|
||||||
var holidays = await _holidayQueryService.GetHolidaysInDates(start, end) ;
|
var holidays = await _holidayQueryService.GetHolidaysInDates(start, end);
|
||||||
int mandatoryHours = 0;
|
int mandatoryHours = 0;
|
||||||
for (var currentDay = persianStart; currentDay <= persianEnd; currentDay = currentDay.AddDays(1))
|
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);
|
Console.WriteLine((int)getDaySetting.ShiftDuration.TotalMinutes + " " + currentDay + " - " + day);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//حقوق نهایی
|
//حقوق نهایی
|
||||||
var monthlySalaryPay = (totalHoursWorked * monthlySalaryDefined) / mandatoryHours;
|
var monthlySalaryPay = (totalHoursWorked * monthlySalaryDefined) / mandatoryHours;
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ namespace Shared.Contracts.Holidays;
|
|||||||
|
|
||||||
public record HolidayDto
|
public record HolidayDto
|
||||||
{
|
{
|
||||||
public DateTime Holidaydate { get; private set; }
|
public DateTime Holidaydate { get; set; }
|
||||||
public long HolidayId { get; private set; }
|
public long HolidayId { get; set; }
|
||||||
public string HolidayYear { get; private set; }
|
public string HolidayYear { get; set; }
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user