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 fsHeads = new List(); 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 fsHeads = new List(); 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 items = new List(); 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 items = new List(); 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 items = new List(); 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 items = new List(); 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 items = new List(); 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 items = new List(); 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(); } } }