66 lines
2.4 KiB
C#
66 lines
2.4 KiB
C#
using _0_Framework.Application;
|
||
using Company.Domain.EmployeeAgg;
|
||
using CompanyManagment.App.Contracts.InsuranceList;
|
||
using CompanyManagment.App.Contracts.Leave;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using ServiceHost.BaseControllers;
|
||
using System.Security.Cryptography;
|
||
|
||
namespace ServiceHost.Areas.Client.Controllers;
|
||
|
||
public class LeaveController : ClientBaseController
|
||
{
|
||
private readonly ILeaveApplication _leaveApplication;
|
||
private long _workshopId;
|
||
public LeaveController(ILeaveApplication leaveApplication, IAuthHelper authHelper)
|
||
{
|
||
_leaveApplication = leaveApplication;
|
||
_workshopId = authHelper.GetWorkshopId();
|
||
}
|
||
|
||
/// <summary>
|
||
/// دریافت لیست مرخصی ها
|
||
/// </summary>
|
||
/// <param name="searchModel"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("GetLeaveList")]
|
||
public async Task<ActionResult<LeaveListMultipleDto>> GetLeaveList(LeaveListSearchModel searchModel)
|
||
{
|
||
var result = new LeaveListMultipleDto();
|
||
searchModel.WorkshopId = _workshopId;
|
||
if (searchModel.EmployeeId > 0)
|
||
{
|
||
//لیست گروه بندی شده
|
||
result.GroupLeaveListDto = await _leaveApplication.GetGroupList(searchModel);
|
||
|
||
if (!string.IsNullOrWhiteSpace(searchModel.YearStr) && !string.IsNullOrWhiteSpace(searchModel.MonthStr))
|
||
{
|
||
TimeSpan timeSpan = _leaveApplication.SumOfEmployeeLeaveTimeSpanInDates(_workshopId, searchModel.EmployeeId, searchModel.YearStr, searchModel.MonthStr, searchModel.LeaveType);
|
||
//مجموع مرخصی پرسنل
|
||
result.SumOfEmployeeleaves = timeSpan.ToFarsiDaysAndHoursAndMinutes();
|
||
}
|
||
|
||
return Ok(result);
|
||
}
|
||
//لیست نرمال PageResult
|
||
result.leaveListDto = await _leaveApplication.GetList(searchModel);
|
||
return Ok(result);
|
||
}
|
||
|
||
|
||
|
||
[HttpGet("print/{id}")]
|
||
public async Task<ActionResult<LeavePrintResponseViewModel>> PrintOneAsync(long id)
|
||
{
|
||
var leavePrint = await _leaveApplication.PrintOneAsync(id, _workshopId);
|
||
return leavePrint;
|
||
}
|
||
[HttpGet("print")]
|
||
public async Task<ActionResult<List<LeavePrintResponseViewModel>>> PrintAllAsync([FromQuery] List<long> ids)
|
||
{
|
||
var leavePrints = await _leaveApplication.PrintAllAsync(ids, _workshopId);
|
||
return Ok(leavePrints);
|
||
}
|
||
|
||
}
|