add new features : WorkFlow - SubAccount - [reward - loan - fine - salaryAid] - CustomizeWorkshopSettings ...

This commit is contained in:
SamSys
2024-12-02 02:52:59 +03:30
parent d7dc78eeea
commit db1b729717
534 changed files with 54731 additions and 5113 deletions

View File

@@ -0,0 +1,6 @@
namespace WorkFlow.Application.Contracts;
public class Class1
{
}

View File

@@ -0,0 +1,9 @@
namespace WorkFlow.Application.Contracts.RollCallConfirmedAbsence;
public class CreateRollCallConfirmedAbsence
{
public string AbsenceDate { get; set; }
public long WorkshopId { get; set; }
public long EmployeeId { get; set; }
public long ConfirmedByAccountId { get; set; }
}

View File

@@ -0,0 +1,12 @@
namespace WorkFlow.Application.Contracts.RollCallConfirmedAbsence;
public class RollCallConfirmAbsenceViewModel
{
public long Id { get; set; }
public string AbsenceDateFa { get; set; }
public DateTime AbsenceDate { get; set; }
public long WorkshopId { get; set; }
public long EmployeeId { get; set; }
public long ConfirmedByAccountId { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak
{
public class CreateRollCallConfirmedWithoutLunchBreak
{
public long RollCallId { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
namespace WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak
{
public class DailyRollCallConfirmedWithoutLunchBreakViewModel
{
public DateTime DateGr { get; set; }
public string DateFa { get; set; }
public int Count { get; set; }
public List<RollCallConfirmedWithoutLunchBreakViewModel> RollCallConfirmedWithoutLunchList { get; set; } =
new();
public string DayOfWeekFa { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak
{
public class RollCallConfirmedWithoutLunchBreakViewModel
{
public long EmployeeId { get; set; }
public long RollCallId { get; set; }
public string EmployeeName { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
#nullable disable
namespace WorkFlow.Application.Contracts.Shared;
public record DailyRollCallWorkFlowViewModel
{
public string DateTimeFa { get; set; }
public DateTime DateTime { get; set; }
public List<RollCallWorkFlowViewModel> RollCallWorkFlowPerDayViewModels { get; set; } = new();
public int RollCallWorkFlowPerDayCount { get; set; }
public string DayOfWeekFa { get; set; }
public bool IsHoliday { get; set; }
public bool IsFriday { get; set; }
}

View File

@@ -0,0 +1,12 @@
#nullable disable
namespace WorkFlow.Application.Contracts.Shared;
public class RollCallWorkFlowViewModel
{
public long EmployeeId { get; set; }
public string EmployeeName { get; set; }
public long WorkshopId { get; set; }
public string Message { get; set; }
public long RollCallId { get; set; }
public DateTime RollCallDate { get; set; }
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\0_Framework\0_Framework.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,34 @@
using _0_Framework.Application;
using WorkFlow.Application.Contracts.RollCallConfirmedAbsence;
using WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak;
using WorkFlow.Application.Contracts.Shared;
namespace WorkFlow.Application.Contracts.WorkFlow;
public interface IWorkFlowApplication
{
OperationResult CreateRollCallConfirmedAbsence(CreateRollCallConfirmedAbsence command);
OperationResult CreateRollCallConfirmedWithoutLunchBreak(CreateRollCallConfirmedWithoutLunchBreak command);
int GetCountAllWorkFlows(long workshopId);
int GetRollCallAbsentsWorkFlows(long workshopId);
int GetCountCutRollCallByBgService(long workshopId);
int GetAllWorkFlowCount(long workshopId);
DailyRollCallWorkFlowViewModel GetAbsentRollCallWorkFlowsByDate(long workshopId, DateTime date);
DailyRollCallConfirmedWithoutLunchBreakViewModel GetEmployeesWithoutLunchBreakByDate(long workshopId, DateTime date);
DailyRollCallWorkFlowViewModel GetRollCallWorkFlowsCutByBgServiceByDate(long workshopId, DateTime date);
List<RollCallConfirmAbsenceViewModel> GetConfirmAbsencesBy(long workshopId, DateTime start, DateTime end);
List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId);
List<DailyRollCallWorkFlowViewModel> GetAbsentRollCallWorkFlows(long workshopId);
List<DailyRollCallConfirmedWithoutLunchBreakViewModel> GetEmployeesWithoutLunchBreak(long workshopId);
List<(long Id, string Name)> GetEmployeesWithoutGroup(long workshopId);
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Domain\WorkFlow.Domain\WorkFlow.Domain.csproj" />
<ProjectReference Include="..\..\Infrastructure\WorkFlow.Infrastructure.ACL\WorkFlow.Infrastructure.ACL.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,395 @@
using _0_Framework.Application;
using CompanyManagment.App.Contracts.RollCallService;
using Microsoft.EntityFrameworkCore.Storage.Json;
using WorkFlow.Application.Contracts.RollCallConfirmedAbsence;
using WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak;
using WorkFlow.Application.Contracts.Shared;
using WorkFlow.Application.Contracts.WorkFlow;
using WorkFlow.Domain.RollCallConfirmedAbsenceAgg;
using WorkFlow.Domain.RollCallConfirmedWithoutLunchBreakAgg;
using WorkFlow.Infrastructure.ACL.Checkout;
using WorkFlow.Infrastructure.ACL.CustomizedWorkshopSettings;
using WorkFlow.Infrastructure.ACL.RollCall;
namespace WorkFlow.Application;
public class WorkFlowApplication : IWorkFlowApplication
{
private readonly IRollCallConfirmedAbsenceRepository _absenceRepository;
private readonly IWorkFlowRollCallACL _rollCallACL;
private readonly IWorkFlowCheckoutACL _checkoutACL;
private readonly IWorkFlowCustomizedWorkshopSettingsACL _customizedWorkshopSettingsACL;
private readonly IRollCallConfirmedWithoutLunchBreakRepository _rollCallConfirmedWithoutLunchBreakRepository;
public WorkFlowApplication(IRollCallConfirmedAbsenceRepository absenceRepository, IWorkFlowRollCallACL rollCallACL, IWorkFlowCheckoutACL checkoutACL, IWorkFlowCustomizedWorkshopSettingsACL customizedWorkshopSettingsACL, IRollCallConfirmedWithoutLunchBreakRepository rollCallConfirmedWithoutLunchBreakRepository)
{
_absenceRepository = absenceRepository;
_rollCallACL = rollCallACL;
_checkoutACL = checkoutACL;
_customizedWorkshopSettingsACL = customizedWorkshopSettingsACL;
_rollCallConfirmedWithoutLunchBreakRepository = rollCallConfirmedWithoutLunchBreakRepository;
}
public OperationResult CreateRollCallConfirmedAbsence(CreateRollCallConfirmedAbsence command)
{
OperationResult op = new OperationResult();
if (!command.AbsenceDate.TryToGeorgianDateTime(out var absenceDateGe))
{
throw new InvalidDataException("تاریخ را به درستی وارد کنید");
}
var entity = new RollCallConfirmedAbsence(command.WorkshopId, command.EmployeeId, absenceDateGe,
command.ConfirmedByAccountId);
_absenceRepository.Create(entity);
_absenceRepository.SaveChanges();
return op.Succcedded();
}
public OperationResult CreateRollCallConfirmedWithoutLunchBreak(CreateRollCallConfirmedWithoutLunchBreak command)
{
OperationResult op = new();
var entity = _rollCallACL.GetDetails(command.RollCallId);
if (entity == null)
return op.Failed("خطای سیستمی");
var newEntity = new RollCallConfirmedWithoutLunchBreak(command.RollCallId, entity.EmployeeId, entity.WorkshopId, entity.RollCallDate);
_rollCallConfirmedWithoutLunchBreakRepository.Create(newEntity);
_rollCallConfirmedWithoutLunchBreakRepository.SaveChanges();
return op.Succcedded();
}
public int GetCountAllWorkFlows(long workshopId)
{
int count = 0;
count += GetAllWorkFlowCount(workshopId);
return count;
}
public int GetRollCallAbsentsWorkFlows(long workshopId)
{
var now = DateTime.Now;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
return _rollCallACL.GetRollCallAbsentsWorkFlowsCount(workshopId, now, twoMonthsAgo);
}
public int GetCountCutRollCallByBgService(long workshopId)
{
return GetRollCallWorkFlowsCutByBgService(workshopId).Count;
}
public int GetAllWorkFlowCount(long workshopId)
{
var count = 0;
var activeServiceByWorkshopId = _rollCallACL.GetActiveServiceByWorkshopId(workshopId);
if (activeServiceByWorkshopId == null)
{
return count;
}
//count += _rollCallACL.GetRollCallAbsentsWorkFlows(accId, workshopId);
count += GetAbsentRollCallWorkFlows(workshopId).Count;
count += GetRollCallWorkFlowsCutByBgService(workshopId).Count;
count += GetEmployeesWithoutLunchBreak(workshopId).Count;
return count;
}
public DailyRollCallWorkFlowViewModel GetAbsentRollCallWorkFlowsByDate(long workshopId, DateTime date)
{
var startOfDay = date.Date;
var endOfDay = startOfDay.AddDays(1).Date.AddTicks(-1);
startOfDay.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, DateTime.Now);
var absences = _rollCallACL.GetAbsentRollCallWorkFlows(workshopId, startOfDay, endOfDay);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, startOfDay, endOfDay);
var confirmedAbssences = GetConfirmAbsencesBy(workshopId, startOfDay, endOfDay);
//var groupedConfirmedAbssencesByDate = confirmedAbssences.GroupBy(x => x.AbsenceDate.Date).ToList();
//List<DailyRollCallWorkFlowViewModel> result = new();
////iterating day by day in absences
//foreach (var item in absences)
//{
var allAbsencesInDate = absences.FirstOrDefault();
if (allAbsencesInDate == null)
return new();
var newItem = new DailyRollCallWorkFlowViewModel()
{
DateTime = date.Date,
DateTimeFa = date.ToFarsi()
};
//dont count absences before the last checkout
var absencesWithoutCheckout = allAbsencesInDate.RollCallWorkFlowPerDayViewModels
.Where(x => !lastCheckouts.Any(y => x.EmployeeId == y.EmployeeId && y.CheckoutStart <= date && y.CheckoutEnd >= date) &&
activeEmployees.Any(y=>y.EmployeeId == x.EmployeeId) );
if (confirmedAbssences != null)
{
newItem.RollCallWorkFlowPerDayViewModels = absencesWithoutCheckout
.Where(x => confirmedAbssences.All(y => x.EmployeeId != y.EmployeeId))
.Select(x => new RollCallWorkFlowViewModel()
{
EmployeeId = x.EmployeeId,
EmployeeName = x.EmployeeName,
Message = "",
RollCallDate = x.RollCallDate,
RollCallId = x.RollCallId,
WorkshopId = x.WorkshopId
}).ToList();
}
else
{
newItem.RollCallWorkFlowPerDayViewModels = absencesWithoutCheckout.Select(x => new RollCallWorkFlowViewModel()
{
EmployeeId = x.EmployeeId,
EmployeeName = x.EmployeeName,
Message = "",
RollCallDate = x.RollCallDate,
RollCallId = x.RollCallId,
WorkshopId = x.WorkshopId
}).ToList();
}
newItem.DayOfWeekFa = newItem.DateTime.DayOfWeek.DayOfWeeKToPersian();
return newItem;
}
public DailyRollCallConfirmedWithoutLunchBreakViewModel GetEmployeesWithoutLunchBreakByDate(long workshopId, DateTime date)
{
var startOfDay = date.Date;
var endOfDay = startOfDay.AddDays(1).Date.AddTicks(-1);
startOfDay.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, DateTime.Now);
var notSlicedRollCalls = _rollCallACL.GetNotSlicedRollCallsByWorkshopId(workshopId, startOfDay, endOfDay);
var employeesWithoutBreakTime = _customizedWorkshopSettingsACL.GetEmployeesWithoutBreakTime(workshopId);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, startOfDay, endOfDay);
notSlicedRollCalls = notSlicedRollCalls
.Where(x => !lastCheckouts.Any(y => y.EmployeeId == x.EmployeeId && y.CheckoutStart.Date <= x.RollCallDate.Date &&
y.CheckoutEnd.Date >= x.RollCallDate.Date) && activeEmployees.Any(y=>y.EmployeeId == x.EmployeeId)).ToList();
var employeeWithoutBreakTimeAndNotSliced = notSlicedRollCalls.Join(employeesWithoutBreakTime, x => x.EmployeeId, y => y.EmployeeId, (x, y) =>
new { y.EmployeeId, x.EmployeeName, x.RollCallId, x.RollCallDate }).ToList();
var entites = _rollCallConfirmedWithoutLunchBreakRepository.GetByWorkshopId(workshopId, startOfDay, endOfDay).ToList();
return new DailyRollCallConfirmedWithoutLunchBreakViewModel()
{
DateFa = date.ToFarsi(),
DateGr = date.Date,
DayOfWeekFa = date.DayOfWeek.DayOfWeeKToPersian(),
RollCallConfirmedWithoutLunchList = employeeWithoutBreakTimeAndNotSliced
.Where(x => !entites.Any(y => y.RollCallId == x.RollCallId)).Select(y => new RollCallConfirmedWithoutLunchBreakViewModel
{
EmployeeId = y.EmployeeId,
EmployeeName = y.EmployeeName,
RollCallId = y.RollCallId
}).ToList()
};
}
public DailyRollCallWorkFlowViewModel GetRollCallWorkFlowsCutByBgServiceByDate(long workshopId, DateTime date)
{
var startOfDay = date.Date;
var endOfDay = startOfDay.AddDays(1).Date.AddTicks(-1);
startOfDay.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, DateTime.Now.Date);
var rollCalls = _rollCallACL.GetRollCallWorkFlowsCutByBgService(workshopId, startOfDay, endOfDay);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, startOfDay, endOfDay);
var rollCallsForDate = rollCalls.FirstOrDefault();
if (rollCallsForDate == null)
return new();
var result = new DailyRollCallWorkFlowViewModel()
{
DateTime = date.Date,
DateTimeFa = date.ToFarsi(),
RollCallWorkFlowPerDayViewModels = rollCallsForDate.RollCallWorkFlowPerDayViewModels
.Where(y => !lastCheckouts.Any(z => z.EmployeeId == y.EmployeeId && z.CheckoutStart.Date <= rollCallsForDate.DateTime.Date &&
z.CheckoutEnd.Date >= rollCallsForDate.DateTime.Date) && activeEmployees.Any(z=>y.EmployeeId==z.EmployeeId))
.Select(e => new RollCallWorkFlowViewModel()
{
EmployeeId = e.EmployeeId,
EmployeeName = e.EmployeeName,
Message = e.Message,
RollCallId = e.RollCallId
}).ToList(),
DayOfWeekFa = date.DayOfWeek.DayOfWeeKToPersian()
};
return result;
}
public List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId)
{
var now = DateTime.Now;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, now);
var rollCalls = _rollCallACL.GetRollCallWorkFlowsCutByBgService(workshopId, twoMonthsAgo, now);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, twoMonthsAgo, now);
return rollCalls.Select(x => new DailyRollCallWorkFlowViewModel()
{
DateTime = x.DateTime,
DateTimeFa = x.DateTimeFa,
RollCallWorkFlowPerDayViewModels = x.RollCallWorkFlowPerDayViewModels
.Where(y => !lastCheckouts.Any(z => z.EmployeeId == y.EmployeeId && z.CheckoutStart.Date <= x.DateTime.Date &&
z.CheckoutEnd.Date >= x.DateTime.Date) && activeEmployees.Any(z=>z.EmployeeId == y.EmployeeId && x.DateTime.Date >= z.startActive &&
x.DateTime.Date <= z.endActive))
.Select(e => new RollCallWorkFlowViewModel()
{
EmployeeId = e.EmployeeId,
EmployeeName = e.EmployeeName,
Message = e.Message,
RollCallId = e.RollCallId
}).ToList(),
DayOfWeekFa = x.DateTime.DayOfWeek.DayOfWeeKToPersian()
}).Where(y => y.RollCallWorkFlowPerDayViewModels != null && y.RollCallWorkFlowPerDayViewModels.Any()).ToList();
}
public List<DailyRollCallWorkFlowViewModel> GetAbsentRollCallWorkFlows(long workshopId)
{
var now = DateTime.Now;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, now);
var absences = _rollCallACL.GetAbsentRollCallWorkFlows(workshopId, twoMonthsAgo, now);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, twoMonthsAgo, now);
var confirmedAbssences = GetConfirmAbsencesBy(workshopId, twoMonthsAgo,
now);
var groupedConfirmedAbssencesByDate = confirmedAbssences.GroupBy(x => x.AbsenceDate.Date).ToList();
List<DailyRollCallWorkFlowViewModel> result = new();
//iterating day by day in absences
foreach (var item in absences)
{
var allAbsencesInDate = item.RollCallWorkFlowPerDayViewModels;
var confirmedAbssencesInDate = groupedConfirmedAbssencesByDate.FirstOrDefault(x => x.Key == item.DateTime.Date);
//set the date of new item
var newItem = new DailyRollCallWorkFlowViewModel()
{
DateTime = item.DateTime,
DateTimeFa = item.DateTime.ToFarsi()
};
//dont count absences before the last checkout
allAbsencesInDate = allAbsencesInDate.Where(x => !lastCheckouts.Any(y =>
x.EmployeeId == y.EmployeeId && y.CheckoutStart<= item.DateTime.Date && y.CheckoutEnd >= item.DateTime.Date) && activeEmployees.Any(y=>
item.DateTime.Date >= y.startActive && item.DateTime.Date <= y.endActive)).ToList();
if (confirmedAbssencesInDate != null)
{
newItem.RollCallWorkFlowPerDayViewModels = allAbsencesInDate
.Where(x => confirmedAbssencesInDate.All(y => x.EmployeeId != y.EmployeeId))
.Select(x => new RollCallWorkFlowViewModel()
{
EmployeeId = x.EmployeeId,
EmployeeName = x.EmployeeName,
Message = ""
}).ToList();
}
else
{
newItem.RollCallWorkFlowPerDayViewModels = allAbsencesInDate.Select(x => new RollCallWorkFlowViewModel()
{
EmployeeId = x.EmployeeId,
EmployeeName = x.EmployeeName,
Message = ""
}).ToList();
}
newItem.DayOfWeekFa = newItem.DateTime.DayOfWeek.DayOfWeeKToPersian();
if (newItem.RollCallWorkFlowPerDayViewModels.Count > 0)
result.Add(newItem);
}
return result;
}
public List<DailyRollCallConfirmedWithoutLunchBreakViewModel> GetEmployeesWithoutLunchBreak(long workshopId)
{
var now = DateTime.Now.Date;
now.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, now);
var notSlicedRollCalls = _rollCallACL.GetNotSlicedRollCallsByWorkshopId(workshopId, twoMonthsAgo, now);
var employeesWithoutBreakTime = _customizedWorkshopSettingsACL.GetEmployeesWithoutBreakTime(workshopId);
notSlicedRollCalls = notSlicedRollCalls
.Where(x => !lastCheckouts.Any(y => y.EmployeeId == x.EmployeeId && y.CheckoutStart.Date <= x.RollCallDate.Date && y.CheckoutEnd.Date >= x.RollCallDate.Date)).ToList();
var employeeWithoutBreakTimeAndNotSliced = notSlicedRollCalls.Join(employeesWithoutBreakTime, x => x.EmployeeId, y => y.EmployeeId, (x, y) =>
new { y.EmployeeId, x.EmployeeName, x.RollCallId, x.RollCallDate }).ToList();
var entites = _rollCallConfirmedWithoutLunchBreakRepository.GetByWorkshopId(workshopId, twoMonthsAgo, now).ToList();
return employeeWithoutBreakTimeAndNotSliced.Where(x => !entites.Any(y => y.RollCallId == x.RollCallId))
.GroupBy(x => x.RollCallDate.Date).OrderBy(x => x.Key).Select(x => new DailyRollCallConfirmedWithoutLunchBreakViewModel
{
DateGr = x.Key.Date,
DateFa = x.Key.Date.ToFarsi(),
DayOfWeekFa = x.Key.DayOfWeek.DayOfWeeKToPersian(),
RollCallConfirmedWithoutLunchList = x.Select(y => new RollCallConfirmedWithoutLunchBreakViewModel
{
EmployeeId = y.EmployeeId,
EmployeeName = y.EmployeeName,
RollCallId = y.RollCallId
}).ToList()
}).ToList();
}
public List<(long Id, string Name)> GetEmployeesWithoutGroup(long workshopId)
{
return _customizedWorkshopSettingsACL.GetEmployeesWithoutGroup(workshopId);
}
public List<RollCallConfirmAbsenceViewModel> GetConfirmAbsencesBy(long workshopId, DateTime start, DateTime end)
{
return _absenceRepository.GetConfirmAbsencesBy(workshopId, start, end);
}
}

View File

@@ -0,0 +1,9 @@
using _0_Framework.Domain;
using WorkFlow.Application.Contracts.RollCallConfirmedAbsence;
namespace WorkFlow.Domain.RollCallConfirmedAbsenceAgg;
public interface IRollCallConfirmedAbsenceRepository : IRepository<long, RollCallConfirmedAbsence>
{
List<RollCallConfirmAbsenceViewModel> GetConfirmAbsencesBy(long workshopId, DateTime start, DateTime end);
}

View File

@@ -0,0 +1,25 @@
using _0_Framework.Application;
using _0_Framework.Domain;
namespace WorkFlow.Domain.RollCallConfirmedAbsenceAgg;
public class RollCallConfirmedAbsence : EntityBase
{
public RollCallConfirmedAbsence(long workshopId, long employeeId, DateTime absenceDate, long confirmedByAccountId)
{
AbsenceDate = absenceDate;
WorkshopId = workshopId;
EmployeeId = employeeId;
ConfirmedByAccountId = confirmedByAccountId;
}
public DateTime AbsenceDate { get; private set; }
public long WorkshopId { get; private set; }
public long EmployeeId { get; private set; }
public long ConfirmedByAccountId { get; private set; }
}

View File

@@ -0,0 +1,11 @@
using _0_Framework.Domain;
using WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak;
namespace WorkFlow.Domain.RollCallConfirmedWithoutLunchBreakAgg
{
public interface IRollCallConfirmedWithoutLunchBreakRepository : IRepository<long, RollCallConfirmedWithoutLunchBreak>
{
List<RollCallConfirmedWithoutLunchBreakViewModel> GetByWorkshopId(long workshopId, DateTime start, DateTime end);
}
}

View File

@@ -0,0 +1,21 @@
using _0_Framework.Domain;
namespace WorkFlow.Domain.RollCallConfirmedWithoutLunchBreakAgg
{
public class RollCallConfirmedWithoutLunchBreak : EntityBaseWithoutCreationDate
{
public long RollCallId { get; private set; }
public long EmployeeId { get; private set; }
public long WorkshopId { get; private set; }
public DateTime RollCallDate { get; private set; }
public RollCallConfirmedWithoutLunchBreak(long rollCallId, long employeeId, long workshopId, DateTime rollCallDate)
{
RollCallId = rollCallId;
EmployeeId = employeeId;
WorkshopId = workshopId;
RollCallDate = rollCallDate;
}
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Application\WorkFlow.Application.Contracts\WorkFlow.Application.Contracts.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,37 @@
using CompanyManagment.App.Contracts.Checkout;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkFlow.Infrastructure.ACL.Checkout
{
public interface IWorkFlowCheckoutACL
{
List<(long EmployeeId, DateTime CheckoutStart, DateTime CheckoutEnd)> GetLastCheckoutsByWorkshopId(
long workshopId, DateTime start, DateTime end);
List<(long EmployeeId, DateTime CheckoutStart, DateTime CheckoutEnd)> GetLastCheckoutsByWorkshopIdForWorkFlow(
long workshopId, DateTime start, DateTime end);
}
public class WorkFlowCheckoutACL : IWorkFlowCheckoutACL
{
private readonly ICheckoutApplication _checkoutApplication;
public WorkFlowCheckoutACL(ICheckoutApplication checkoutApplication)
{
_checkoutApplication = checkoutApplication;
}
public List<(long EmployeeId, DateTime CheckoutStart, DateTime CheckoutEnd)> GetLastCheckoutsByWorkshopId(long workshopId, DateTime start, DateTime end)
{
return _checkoutApplication.GetLastCheckoutsByWorkshopId(workshopId, start, end);
}
public List<(long EmployeeId, DateTime CheckoutStart, DateTime CheckoutEnd)> GetLastCheckoutsByWorkshopIdForWorkFlow(long workshopId, DateTime start, DateTime end)
{
return _checkoutApplication.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, start, end);
}
}
}

View File

@@ -0,0 +1,8 @@
namespace WorkFlow.Infrastructure.ACL.CustomizedWorkshopSettings
{
public interface IWorkFlowCustomizedWorkshopSettingsACL
{
List<(long Id, string Name)> GetEmployeesWithoutGroup(long workshopId);
List<(long EmployeeId, string Name)> GetEmployeesWithoutBreakTime(long workshopId);
}
}

View File

@@ -0,0 +1,37 @@
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
namespace WorkFlow.Infrastructure.ACL.CustomizedWorkshopSettings
{
public class WorkFlowCustomizedWorkshopSettingsACL : IWorkFlowCustomizedWorkshopSettingsACL
{
private readonly ICustomizeWorkshopSettingsApplication _customizeWorkshopSettingsApplication;
public WorkFlowCustomizedWorkshopSettingsACL(ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication)
{
_customizeWorkshopSettingsApplication = customizeWorkshopSettingsApplication;
}
public List<(long Id, string Name)> GetEmployeesWithoutGroup(long workshopId)
{
var workshopSettingsDetails = _customizeWorkshopSettingsApplication
.GetWorkshopSettingsDetails(workshopId);
if (workshopSettingsDetails.WorkshopShiftStatus != WorkshopShiftStatus.Irregular)
return new();
return _customizeWorkshopSettingsApplication.GetEmployeesWithoutGroup(workshopSettingsDetails.Id).Select(x => (x.Id, x.EmployeeFullName))
.ToList();
}
public List<(long EmployeeId, string Name)> GetEmployeesWithoutBreakTime(long workshopId)
{
var list = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByWorkshopId(workshopId);
return list.Where(x => x.BreakTime.BreakTimeType == BreakTimeType.WithoutTime)
.Select(x => (x.EmployeeId, x.EmployeeFullName)).ToList();
}
}
}

View File

@@ -0,0 +1,32 @@
using CompanyManagment.App.Contracts.RollCallService;
using WorkFlow.Application.Contracts.Shared;
namespace WorkFlow.Infrastructure.ACL.RollCall;
// ReSharper disable once InconsistentNaming
public interface IWorkFlowRollCallACL
{
/// <summary>
/// این متد تمام حضور غیاب های کات شده توسط بک گراند سرویس را به صورت تعداد روزانه برمیگرداند
/// </summary>
/// <param name="accountId"></param>
/// <param name="workshopId"></param>
/// <returns> لیستی از تعداد و روز آن</returns>
List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId, DateTime start, DateTime end);
/// <summary>
/// تمامی حضور غیاب های کات شده توسط بک گراند سرویس را برمیگرداند
/// </summary>
/// <param name="accId"></param>
/// <param name="workshopId"></param>
/// <returns></returns>
int GetCountCutRollCallByBgService(long workshopId);
List<RollCallWorkFlowViewModel> GetNotSlicedRollCallsByWorkshopId(long workshopId, DateTime durationStart, DateTime durationEnd);
int GetRollCallAbsentsWorkFlowsCount(long workshopId, DateTime durationEnd, DateTime durationStart);
List<(long EmployeeId, string EmployeeName, DateTime startActive, DateTime endActive)>
GetActiveWorkshopRollCallEmployees(long workshopId, DateTime start, DateTime end);
List<DailyRollCallWorkFlowViewModel> GetAbsentRollCallWorkFlows(long workshopId, DateTime durationStart, DateTime durationEnd);
RollCallWorkFlowViewModel GetDetails(long rollCallId);
RollCallServiceViewModel GetActiveServiceByWorkshopId(long workshopId);
}

View File

@@ -0,0 +1,118 @@
using _0_Framework.Application;
using CompanyManagment.App.Contracts.RollCall;
using CompanyManagment.App.Contracts.RollCallEmployee;
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
using CompanyManagment.App.Contracts.RollCallService;
using WorkFlow.Application.Contracts.Shared;
namespace WorkFlow.Infrastructure.ACL.RollCall;
public class WorkFlowRollCallACL : IWorkFlowRollCallACL
{
private readonly IRollCallApplication _rollCallApplication;
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication;
private readonly IRollCallServiceApplication _rollCallServiceApplication;
public WorkFlowRollCallACL(IRollCallApplication rollCallApplication, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallEmployeeApplication rollCallEmployeeApplication, IRollCallServiceApplication rollCallServiceApplication)
{
_rollCallApplication = rollCallApplication;
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
_rollCallEmployeeApplication = rollCallEmployeeApplication;
_rollCallServiceApplication = rollCallServiceApplication;
}
public List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId, DateTime start, DateTime end)
{
return _rollCallApplication.GetRollCallWorkFlowsCutByBgService(workshopId, start, end).Select(x =>
{
return new DailyRollCallWorkFlowViewModel()
{
DateTime = x.DateGr,
DateTimeFa = x.DateFa,
RollCallWorkFlowPerDayViewModels = x.ActiveEmployees.Select(e => new RollCallWorkFlowViewModel()
{
EmployeeId = e.EmployeeId,
EmployeeName = e.EmployeeFullName,
Message = $"{TimeOnly.FromDateTime(e.StartDate!.Value):HH:mm} الی {TimeOnly.FromDateTime(e.EndDate.Value):HH:mm}",
RollCallId = e.Id
}).ToList(),
DayOfWeekFa = x.DateGr.DayOfWeek.DayOfWeeKToPersian(),
};
}).Where(x => x.RollCallWorkFlowPerDayViewModels.Count > 0).ToList();
}
public List<(long EmployeeId, string EmployeeName,DateTime startActive,DateTime endActive)> GetActiveWorkshopRollCallEmployees(long workshopId, DateTime start, DateTime end)
{
return _rollCallEmployeeStatusApplication.GetActiveByWorkshopIdInDate(workshopId, start, end).Select(x => (x.EmployeeId, x.EmployeeName,x.StartDateGr,x.EndDateGr))
.ToList();
}
public int GetCountCutRollCallByBgService(long workshopId)
{
var now = DateTime.Now;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
return GetRollCallWorkFlowsCutByBgService(workshopId, twoMonthsAgo, now).Count;
}
public int GetRollCallAbsentsWorkFlowsCount(long workshopId, DateTime durationEnd, DateTime durationStart)
{
return GetAbsentRollCallWorkFlows(workshopId, durationStart, durationEnd).Count;
}
public List<DailyRollCallWorkFlowViewModel> GetAbsentRollCallWorkFlows(long workshopId, DateTime durationStart, DateTime durationEnd)
{
return _rollCallApplication.GetWorkshopAbsentHistory(workshopId, durationStart, durationEnd).Select(x => new DailyRollCallWorkFlowViewModel()
{
IsHoliday = x.IsHoliday,
DateTime = x.DateGr,
DateTimeFa = x.DateFa,
DayOfWeekFa = x.DayOfWeekFa,
IsFriday = x.IsFriday,
RollCallWorkFlowPerDayViewModels = x.ActiveEmployees.Select(a => new RollCallWorkFlowViewModel()
{
EmployeeId = a.EmployeeId,
Message = "",
EmployeeName = a.EmployeeFullName,
WorkshopId = a.WorkshopId
}).ToList()
}).ToList();
}
public List<RollCallWorkFlowViewModel> GetNotSlicedRollCallsByWorkshopId(long workshopId, DateTime durationStart, DateTime durationEnd)
{
return _rollCallApplication.GetNotSlicedRollCallsByWorkshopId(workshopId, durationStart, durationEnd)
.Select(x => new RollCallWorkFlowViewModel
{
EmployeeId = x.EmployeeId,
EmployeeName = x.EmployeeFullName,
RollCallDate = x.DateGr,
RollCallId = x.Id
}).ToList();
}
public RollCallWorkFlowViewModel GetDetails(long rollCallId)
{
var entity = _rollCallApplication.GetDetails(rollCallId);
if (entity == null)
return null;
return new RollCallWorkFlowViewModel
{
EmployeeId = entity.EmployeeId,
EmployeeName = entity.EmployeeFullName,
RollCallId = rollCallId,
RollCallDate = entity.DateGr.Date,
WorkshopId = entity.WorkshopId
};
}
public RollCallServiceViewModel GetActiveServiceByWorkshopId(long workshopId)
{
return _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopId);
}
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\CompanyManagment.App.Contracts\CompanyManagment.App.Contracts.csproj" />
<ProjectReference Include="..\..\Application\WorkFlow.Application.Contracts\WorkFlow.Application.Contracts.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Application\WorkFlow.Application\WorkFlow.Application.csproj" />
<ProjectReference Include="..\WorkFlow.Infrastructure.EfCore\WorkFlow.Infrastructure.EfCore.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using WorkFlow.Application;
using WorkFlow.Application.Contracts.WorkFlow;
using WorkFlow.Domain.RollCallConfirmedAbsenceAgg;
using WorkFlow.Domain.RollCallConfirmedWithoutLunchBreakAgg;
using WorkFlow.Infrastructure.ACL.Checkout;
using WorkFlow.Infrastructure.ACL.CustomizedWorkshopSettings;
using WorkFlow.Infrastructure.ACL.RollCall;
using WorkFlow.Infrastructure.EfCore;
using WorkFlow.Infrastructure.EfCore.Repository;
namespace WorkFlow.Infrastructure.Config
{
public class WorkFlowBootstrapper
{
public static void Configure(IServiceCollection services, string connectionString)
{
services.AddTransient<IWorkFlowApplication, WorkFlowApplication>();
services.AddTransient<IRollCallConfirmedAbsenceRepository, RollCallConfirmedAbsenceRepository>();
services.AddTransient<IRollCallConfirmedWithoutLunchBreakRepository, RollCallConfirmedWithoutLunchBreakRepository>();
services.AddTransient<IWorkFlowCheckoutACL, WorkFlowCheckoutACL>();
services.AddTransient<IWorkFlowRollCallACL, WorkFlowRollCallACL>();
services.AddTransient<IWorkFlowCustomizedWorkshopSettingsACL, WorkFlowCustomizedWorkshopSettingsACL>();
services.AddDbContext<WorkFlowContext>(x =>
{
x.UseSqlServer(connectionString);
});
}
}
}

View File

@@ -0,0 +1,15 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WorkFlow.Domain.RollCallConfirmedAbsenceAgg;
namespace WorkFlow.Infrastructure.EfCore.Mapping;
public class RollCallConfirmedAbsenceMapping:IEntityTypeConfiguration<RollCallConfirmedAbsence>
{
public void Configure(EntityTypeBuilder<RollCallConfirmedAbsence> builder)
{
builder.ToTable("RollCAllConfirmedAbsences");
builder.HasKey(x => x.id);
}
}

View File

@@ -0,0 +1,15 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WorkFlow.Domain.RollCallConfirmedWithoutLunchBreakAgg;
namespace WorkFlow.Infrastructure.EfCore.Mapping
{
public class RollCallConfirmedWithoutLunchBreakMapping : IEntityTypeConfiguration<RollCallConfirmedWithoutLunchBreak>
{
public void Configure(EntityTypeBuilder<RollCallConfirmedWithoutLunchBreak> builder)
{
builder.ToTable("RollCallsConfirmedWithoutLunchBreak");
builder.HasKey(x => x.id);
}
}
}

View File

@@ -0,0 +1,83 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using WorkFlow.Infrastructure.EfCore;
#nullable disable
namespace WorkFlow.Infrastructure.EfCore.Migrations
{
[DbContext(typeof(WorkFlowContext))]
[Migration("20241201164108_WorkFlowInit")]
partial class WorkFlowInit
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WorkFlow.Domain.RollCallConfirmedAbsenceAgg.RollCallConfirmedAbsence", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<DateTime>("AbsenceDate")
.HasColumnType("datetime2");
b.Property<long>("ConfirmedByAccountId")
.HasColumnType("bigint");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<long>("EmployeeId")
.HasColumnType("bigint");
b.Property<long>("WorkshopId")
.HasColumnType("bigint");
b.HasKey("id");
b.ToTable("RollCAllConfirmedAbsences", (string)null);
});
modelBuilder.Entity("WorkFlow.Domain.RollCallConfirmedWithoutLunchBreakAgg.RollCallConfirmedWithoutLunchBreak", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<long>("EmployeeId")
.HasColumnType("bigint");
b.Property<DateTime>("RollCallDate")
.HasColumnType("datetime2");
b.Property<long>("RollCallId")
.HasColumnType("bigint");
b.Property<long>("WorkshopId")
.HasColumnType("bigint");
b.HasKey("id");
b.ToTable("RollCallsConfirmedWithoutLunchBreak", (string)null);
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,58 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WorkFlow.Infrastructure.EfCore.Migrations
{
/// <inheritdoc />
public partial class WorkFlowInit : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "RollCAllConfirmedAbsences",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AbsenceDate = table.Column<DateTime>(type: "datetime2", nullable: false),
WorkshopId = table.Column<long>(type: "bigint", nullable: false),
EmployeeId = table.Column<long>(type: "bigint", nullable: false),
ConfirmedByAccountId = table.Column<long>(type: "bigint", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RollCAllConfirmedAbsences", x => x.id);
});
migrationBuilder.CreateTable(
name: "RollCallsConfirmedWithoutLunchBreak",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RollCallId = table.Column<long>(type: "bigint", nullable: false),
EmployeeId = table.Column<long>(type: "bigint", nullable: false),
WorkshopId = table.Column<long>(type: "bigint", nullable: false),
RollCallDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RollCallsConfirmedWithoutLunchBreak", x => x.id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RollCAllConfirmedAbsences");
migrationBuilder.DropTable(
name: "RollCallsConfirmedWithoutLunchBreak");
}
}
}

View File

@@ -0,0 +1,80 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using WorkFlow.Infrastructure.EfCore;
#nullable disable
namespace WorkFlow.Infrastructure.EfCore.Migrations
{
[DbContext(typeof(WorkFlowContext))]
partial class WorkFlowContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WorkFlow.Domain.RollCallConfirmedAbsenceAgg.RollCallConfirmedAbsence", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<DateTime>("AbsenceDate")
.HasColumnType("datetime2");
b.Property<long>("ConfirmedByAccountId")
.HasColumnType("bigint");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<long>("EmployeeId")
.HasColumnType("bigint");
b.Property<long>("WorkshopId")
.HasColumnType("bigint");
b.HasKey("id");
b.ToTable("RollCAllConfirmedAbsences", (string)null);
});
modelBuilder.Entity("WorkFlow.Domain.RollCallConfirmedWithoutLunchBreakAgg.RollCallConfirmedWithoutLunchBreak", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<long>("EmployeeId")
.HasColumnType("bigint");
b.Property<DateTime>("RollCallDate")
.HasColumnType("datetime2");
b.Property<long>("RollCallId")
.HasColumnType("bigint");
b.Property<long>("WorkshopId")
.HasColumnType("bigint");
b.HasKey("id");
b.ToTable("RollCallsConfirmedWithoutLunchBreak", (string)null);
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,29 @@
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using WorkFlow.Application.Contracts.RollCallConfirmedAbsence;
using WorkFlow.Domain.RollCallConfirmedAbsenceAgg;
namespace WorkFlow.Infrastructure.EfCore.Repository;
public class RollCallConfirmedAbsenceRepository : RepositoryBase<long, RollCallConfirmedAbsence>, IRollCallConfirmedAbsenceRepository
{
private readonly WorkFlowContext _workFlowContext;
public RollCallConfirmedAbsenceRepository(WorkFlowContext workFlowContext) : base(workFlowContext)
{
_workFlowContext = workFlowContext;
}
public List<RollCallConfirmAbsenceViewModel> GetConfirmAbsencesBy(long workshopId, DateTime start, DateTime end)
{
return _workFlowContext.RollCallConfirmedAbsences.Where(x => x.WorkshopId == workshopId &&
x.AbsenceDate.Date >= start.Date && x.AbsenceDate.Date <= end.Date).Select(x => new RollCallConfirmAbsenceViewModel()
{
AbsenceDate = x.AbsenceDate,
WorkshopId = workshopId,
AbsenceDateFa = x.AbsenceDate.ToFarsi(),
ConfirmedByAccountId = x.ConfirmedByAccountId,
EmployeeId = x.EmployeeId,
Id = x.id
}).ToList();
}
}

View File

@@ -0,0 +1,27 @@
using _0_Framework.InfraStructure;
using WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak;
using WorkFlow.Domain.RollCallConfirmedWithoutLunchBreakAgg;
namespace WorkFlow.Infrastructure.EfCore.Repository;
public class RollCallConfirmedWithoutLunchBreakRepository : RepositoryBase<long, RollCallConfirmedWithoutLunchBreak>, IRollCallConfirmedWithoutLunchBreakRepository
{
private readonly WorkFlowContext _workFlowContext;
public RollCallConfirmedWithoutLunchBreakRepository(WorkFlowContext workFlowContext) : base(workFlowContext)
{
_workFlowContext = workFlowContext;
}
public List<RollCallConfirmedWithoutLunchBreakViewModel> GetByWorkshopId(long workshopId, DateTime start, DateTime end)
{
return _workFlowContext.RollCallsConfirmedWithoutLunchBreak.Where(x => x.WorkshopId == workshopId &&
x.RollCallDate.Date >= start.Date && x.RollCallDate.Date <= end.Date).OrderByDescending(x => x.RollCallDate)
.Select(y => new RollCallConfirmedWithoutLunchBreakViewModel
{
EmployeeId = y.EmployeeId,
RollCallId = y.RollCallId
}).ToList();
}
}

View File

@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Domain\WorkFlow.Domain\WorkFlow.Domain.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore;
using WorkFlow.Domain.RollCallConfirmedAbsenceAgg;
using WorkFlow.Domain.RollCallConfirmedWithoutLunchBreakAgg;
using WorkFlow.Infrastructure.EfCore.Mapping;
namespace WorkFlow.Infrastructure.EfCore;
public class WorkFlowContext : DbContext
{
public DbSet<RollCallConfirmedAbsence> RollCallConfirmedAbsences { get; set; }
public DbSet<RollCallConfirmedWithoutLunchBreak> RollCallsConfirmedWithoutLunchBreak { get; set; }
public WorkFlowContext(DbContextOptions<WorkFlowContext> options) : base(options)
{
}
public WorkFlowContext()
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
var assembly = typeof(RollCallConfirmedAbsenceMapping).Assembly;
modelBuilder.ApplyConfigurationsFromAssembly(assembly);
base.OnModelCreating(modelBuilder);
}
}