Files
Backend-Api/ServiceHost/Areas/Client/Controllers/LeaveController.cs

170 lines
5.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using _0_Framework.Application;
using Company.Domain.EmployeeAgg;
using CompanyManagment.App.Contracts.InstitutionPlan;
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);
}
/// <summary>
/// چک کردن تاریخ شروع مرخصی
/// </summary>
/// <param name="startLeaveDate"></param>
/// <returns></returns>
[HttpGet("CheckIsInvalidLeave")]
public async Task<OperationResult<CheckIsInvalidLeaveDto>> CheckIsInvalidLeave(string startLeaveDate)
{
return await _leaveApplication.CheckIsInvalidLeave(startLeaveDate, _workshopId);
}
/// <summary>
/// ایجاد مرخصی
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
[HttpPost("CreateLeave")]
public async Task<ActionResult<OperationResult>> CreateLeave([FromBody] CreateLeaveDto command)
{
command.WorkshopId = _workshopId;
var result = await _leaveApplication.CreateLeave(command);
return result;
}
/// <summary>
/// دریافت شیفت گردشی اگر داشت
/// </summary>
/// <param name="startLeaveDate"></param>
/// <returns></returns>
[HttpGet("GetRotatingShift")]
public async Task<OperationResult<RotatingShiftDto>> GetRotatingShift(long employeeId, string startLeaveDate)
{
return await _leaveApplication.HasRotatingShift(_workshopId, employeeId, startLeaveDate);
}
/// <summary>
/// محاسبه مدت مرخصی ساعتی
/// </summary>
/// <param name="startHours"></param>
/// <param name="endHours"></param>
/// <returns></returns>
[HttpGet("GetHourlyLeaveDuration")]
public async Task<ActionResult<string>> GetHourlyLeaveDuration(string startHours, string endHours)
{
var result =await _leaveApplication.GetHourlyLeaveDuration(startHours, endHours);
return Ok(new { LeaveDuration = result });
}
/// <summary>
/// محاسبه مدت مرخصی روزانه
/// </summary>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <returns></returns>
[HttpGet("GetDailyLeaveDuration")]
public async Task<ActionResult<string>> GetDailyLeaveDuration(string startDate, string endDate)
{
var result = await _leaveApplication.GetDailyLeaveDuration(startDate, endDate);
return Ok(new { LeaveDuration = result });
}
/// <summary>
/// پرینت تکی
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("print/{id}")]
public async Task<ActionResult<LeavePrintResponseViewModel>> PrintOneAsync(long id)
{
var leavePrint = await _leaveApplication.PrintOneAsync(id, _workshopId);
return leavePrint;
}
/// <summary>
/// پرینت گروهی
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpGet("print")]
public async Task<ActionResult<List<LeavePrintResponseViewModel>>> PrintAllAsync([FromQuery] List<long> ids, LeaveListSearchModel searchModel)
{
var leavePrints = await _leaveApplication.PrintAllAsync(ids, _workshopId);
return Ok(leavePrints);
}
/// <summary>
/// پرینت لیستی
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpGet("ListPrint")]
public async Task<ActionResult<LeaveListPrintDto>> ListPrint([FromQuery] List<long> ids)
{
var leavePrints = await _leaveApplication.ListPrint(ids);
return Ok(leavePrints);
}
/// <summary>
/// حذف مرخصی
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpDelete("RemoveLeave/{id}")]
public async Task<ActionResult<object>> RemoveLeaveAsync(long id)
{
var op =await _leaveApplication.RemoveLeaveAsync(id);
return Ok(new
{
isSuccedded = op.IsSuccedded,
message = op.Message,
});
}
}