EchoTex_Payroll/HRM.UI/Controllers/GrievanceManagement/GrievanceManagementController.cs
2024-10-14 10:01:49 +06:00

524 lines
14 KiB
C#

using HRM.BO;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
namespace HRM.UI.Controllers
{
[Route("api/GrievanceManagement")]
[ApiController]
[Authorize]
public class GrievanceManagementController : ControllerBase
{
#region Dependency
private readonly IComplainService _complainService;
private readonly IDAMasterService _dAMasterService;
private readonly IPunishmentService _punishmentService;
#endregion Dependency
public GrievanceManagementController(IComplainService complainService, IDAMasterService dAMasterService, IPunishmentService punishmentService)
{
_complainService = complainService;
_dAMasterService = dAMasterService;
_punishmentService = punishmentService;
}
#region Complain Controller
#region GetComplainById
[HttpGet("getComplainById/{id}")]
public ActionResult GetComplainById(int id)
{
Complain item = new Complain();
try
{
item = _complainService.Get(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
#endregion GetComplainById
#region GetAllComplains
[HttpGet("getAllComplains")]
public ActionResult GetAllComplains()
{
List<Complain> items = new List<Complain>();
try
{
items = _complainService.Get();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
#endregion GetAllComplains
#region getDAComplainPicker
[HttpGet]
[Route("GetDAComplainPicker/{complainid}/")]
public ActionResult GetDAComplainPicker(int complainid)
{
List<Complain> cvs = new List<Complain>();
try
{
cvs = _complainService.GetDAComplainPicker(complainid);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(cvs);
}
#endregion getDAComplainPicker
#region GetComplainStatus
[HttpGet("getComplainByStatus/{status}")]
public ActionResult GetComplainByStatus(EnumStatus status)
{
List<Complain> items = new List<Complain>();
try
{
items = _complainService.Get(status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
#endregion GetComplainStatus
#region SaveComplain
[HttpPost]
[Route("saveComplain")]
public ActionResult SaveComplain(Complain complain)
{
try
{
_complainService.Save(complain);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
#endregion SaveComplain
#region DeleteComplain
[HttpPost]
[Route("deleteComplain")]
public ActionResult DeleteComplain(int id)
{
try
{
_complainService.Delete(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
#endregion DeleteComplain
#endregion Complain Controller
#region DAMaster Controller
#region GetDAMasterById
[HttpGet("GetDAMasterById/{id}")]
public ActionResult GetDAMasterByID(int id)
{
DAMaster item = new DAMaster();
try
{
item = _dAMasterService.Get(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
#endregion GetDAMasterById
#region GetDAMasterByCode
[HttpGet("getDAMasterByCode/{code}")]
public ActionResult GetDAMasterByID(string code)
{
DAMaster item = new DAMaster();
try
{
item = _dAMasterService.Get(code);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
#endregion GetDAMasterByCode
#region GetDAllDAMasters
[HttpGet]
[Route("GetDAMasters/{fromDate}/{toDate}/{daCode}")]
public ActionResult GetDAMasters(DateTime? fromDate, DateTime? toDate, string daCode)
{
List<DAMaster> cvs = new List<DAMaster>();
daCode = daCode.Equals("null") ? null : daCode;
try
{ cvs = _dAMasterService.GetDAMasters(fromDate, toDate, daCode);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(cvs);
}
#endregion GetDAllDAMasters
#region SaveDAMaster
[HttpPost]
[Route("SaveDAMaster")]
public ActionResult SaveDAMaster(DAMaster dAMaster)
{
try
{
_dAMasterService.Save(dAMaster);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
#endregion SaveDAMaster
#region DeleteDAEmployee
[HttpPost]
[Route("DeleteDAEmployee")]
public ActionResult DeleteDAEmployee(int id)
{
try
{
_dAMasterService.Delete(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
#endregion DeleteDAMaster
#region GetDAEmployee
[HttpGet("GetDAEmployee/{id}")]
public ActionResult GetDAEmployee(int id)
{
List<DAEmployee> items = new List<DAEmployee>();
try
{
id = id.Equals("null") ? 0 : id;
items = _dAMasterService.GetDAEmployees(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
#endregion GetDAEmployee
#region GetDAComplainsById
[HttpGet("getDAComplainsById/{id}")]
public ActionResult GetDAComplainById(int id)
{
List<DAComplain> items = new List<DAComplain>();
try
{
items = _dAMasterService.GetDAComplains(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
#endregion GetDAComplainsById
#region GetDAEmpExplanationsById
[HttpGet("getDAEmpExplanationsById/{id}")]
public ActionResult GetDAEmpExplanationsById(int id)
{
List<DAEmpExplanation> items = new List<DAEmpExplanation>();
try
{
items = _dAMasterService.GetDAEmpExplanations(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
#endregion GetDAEmpExplanationsById
#region GetDAPunishmentsById
[HttpGet("getDAPunishmentsById/{id}")]
public ActionResult GetDAPunishmentsById(int id)
{
List<DAPunishment> items = new List<DAPunishment>();
try
{
items = _dAMasterService.GetDAPunishments(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
#endregion GetDAPunishmentsById
#region GetDAComEmpsById
[HttpGet("getDAComEmpsById/{id}")]
public ActionResult GetDAComEmpsById(int id)
{
List<DAComEmp> items = new List<DAComEmp>();
try
{
items = _dAMasterService.GetDAComEmps(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
#endregion GetDAComEmpsById
#region GetDAPEmployeesById
[HttpGet("getDAPEmployeesById/{id}")]
public ActionResult DAPEmployeesById(int id)
{
List<DAPEmployee> items = new List<DAPEmployee>();
try
{
items = _dAMasterService.GetDAPEmployees(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
#endregion GetDAPEmployeesById
#region GetDAPRIEmpsById
[HttpGet("getDAPRIEmpsById/{id}")]
public ActionResult GetDAPRIEmpsById(int id)
{
List<DAPRIEmp> items = new List<DAPRIEmp>();
try
{
items = _dAMasterService.GetDAPRIEmps(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
#endregion GetDAPRIEmpsById
#endregion DAMaster Controller
#region Punsihment Controller
#region GetPunishmentById
[HttpGet("getPunishmentById/{id}")]
public ActionResult GetPunishmentByID(int id)
{
Punishment item = new Punishment();
try
{
item = _punishmentService.Get(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
#endregion GetPunishmentById
#region getDAPunishmentPIcker
[HttpGet]
[Route("GetDAPunishmentPicker/{punishmentid}/")]
public ActionResult GetDAPunishmentPicker(int punishmentid)
{
List<Punishment> cvs = new List<Punishment>();
try
{
cvs = _punishmentService.GetDAPunishmentPicker(punishmentid);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(cvs);
}
#endregion getDAPunishmentPicker
#region GetAllPunishment
[HttpGet("getAllPunishments")]
public ActionResult GetAllPunishments()
{
List<Punishment> items = new List<Punishment>();
try
{
items = _punishmentService.Get();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
#endregion GetAllPunishment
#region GetPunishmentStatus
[HttpGet("getPunishmentByStatus/{status}")]
public ActionResult GetPunishmentByStatus(EnumStatus status)
{
List<Punishment> items = new List<Punishment>();
try
{
items = _punishmentService.Get(status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
#endregion GetPunishmentStatus
#region SavePunsihment
[HttpPost]
[Route("savePunsihment")]
public ActionResult SavePunsihment(Punishment punishment)
{
try
{
_punishmentService.Save(punishment);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
#endregion SavePunsihment
#region DeletePunishment
[HttpPost]
[Route("deletePunishment")]
public ActionResult DeletePunishment(int id)
{
try
{
_punishmentService.Delete(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
#endregion DeletePunishment
#endregion Punsihment Controller
}
}