EchoTex_Payroll/HRM.UI/Controllers/Payroll/SettlementController.cs

339 lines
8.9 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using HRM.BO;
using HRM.DA;
namespace HRM.UI.Controllers.Payroll
{
[Route("api/settlement")]
[ApiController]
public class SettlementController : ControllerBase
{
private readonly IFSHeadService _fsHeadService;
private readonly IFSTranService _fsTranService;
private readonly IFSTranDetailService _fsTranDetailService;
public SettlementController(IFSHeadService fsHeadService,
IFSTranService fsTranService,
IFSTranDetailService fsTranDetailService)
{
this._fsHeadService = fsHeadService;
this._fsTranService = fsTranService;
this._fsTranDetailService = fsTranDetailService;
}
// FSHead
[HttpGet("getFSHeadById/{id}")]
public ActionResult GetFSHeadById(int id)
{
FSHead fsHead = new FSHead();
try
{
fsHead = _fsHeadService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(fsHead);
}
[HttpGet("getAllFSHead")]
public ActionResult GetAllFSHead()
{
List<FSHead> fsHeads = new List<FSHead>();
try
{
fsHeads = _fsHeadService.Get();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(fsHeads);
}
[HttpGet("getFSHeadByStatus/{status}")]
public ActionResult GetFSHeadByStatus(EnumStatus status)
{
List<FSHead> fsHeads = new List<FSHead>();
try
{
fsHeads = _fsHeadService.Get(status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(fsHeads);
}
[HttpPost]
[Route("saveFSHead")]
public ActionResult SaveFSHead(FSHead fsHead)
{
try
{
_fsHeadService.Save(fsHead);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteFSHead")]
public ActionResult DeleteFSHead(int id)
{
try
{
_fsHeadService.Delete(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
// FSTran
[HttpGet("getFSTranById/{id}")]
public ActionResult GetFSTranById(int id)
{
FSTran item = new FSTran();
try
{
item = _fsTranService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getFSTranByEmpId/{empId}")]
public ActionResult getFSTranByEmpId(int empId)
{
FSTran item = new FSTran();
try
{
item = _fsTranService.GetWithEmpID(empId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getAllFSTran")]
public ActionResult GetAllFSTran()
{
List<FSTran> items = new List<FSTran>();
try
{
items = _fsTranService.Get();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getFSTranByStatus/{status}")]
public ActionResult GetFSTranByStatus(EnumStatus status)
{
List<FSTran> items = new List<FSTran>();
try
{
items = _fsTranService.Get(status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getFSTranByDateRange/{fromDate}/{toDate}")]
public ActionResult GetFSTranByDateRange(DateTime fromDate, DateTime toDate)
{
List<FSTran> items = new List<FSTran>();
try
{
items = _fsTranService.Get(fromDate, toDate,true);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getFSTranByEmpIds/{empIds}")]
public ActionResult GetFSTranByEmpIds(string empIds)
{
List<FSTran> items = new List<FSTran>();
try
{
items = _fsTranService.Get(empIds);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getPFAmount/{employeeNo}")]
public ActionResult GetPFAmount(string employeeNo)
{
double ans;
try
{
ans = _fsTranService.GetPFAmount(employeeNo);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpPost]
[Route("saveFSTran")]
public ActionResult SaveFSTran(FSTran fsTran)
{
try
{
_fsTranService.Save(fsTran);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteFSTran")]
public ActionResult DeleteFSTran(int id)
{
try
{
_fsTranService.Delete(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
// FSTranDetail
[HttpGet("getFSTranDetailById/{id}")]
public ActionResult GetFSTranDetailById(int id)
{
FSTranDetail item = new FSTranDetail();
try
{
item = _fsTranDetailService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getDetail/{tranId}")]
public ActionResult GetDetail(int tranId)
{
List<FSTranDetail> items = new List<FSTranDetail>();
try
{
items = _fsTranDetailService.GetDetail(tranId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDetailByEmp/{empId}")]
public ActionResult GetDetailByEmp(int empId)
{
List<FSTranDetail> items = new List<FSTranDetail>();
try
{
items = _fsTranDetailService.GetDetailByEmp(empId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost]
[Route("saveFSTranDetail")]
public ActionResult SaveFSTranDetail(FSTranDetail item)
{
try
{
_fsTranDetailService.Save(item);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteFSTranDetail")]
public ActionResult DeleteFSTranDetail(int id)
{
try
{
_fsTranDetailService.Delete(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
}
}