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

58 lines
1.2 KiB
C#

using HRM.BO;
using System.Collections.Generic;
using System;
using HRM.UI.Components;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using HRM.UI.MODELS;
namespace HRMobileAPI.Controllers
{
[ApiController]
[Route("api/Mobile/Location")]
[Authorize]
public class LocationController : ControllerBase
{
private readonly ILocationService _locationService;
public LocationController(
ILocationService locationService)
{
this._locationService = locationService;
}
[HttpGet]
[Route("Search")]
public ActionResult Search(string code, string name)
{
try
{
List<LocationTModel> oLocations = _locationService.GetAllLocation(code, name).ConvertToTModels();
return Ok(oLocations);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
}
[HttpGet]
[Route("GetByEmployeeID")]
public ActionResult GetByEmployeeID(int employeeID)
{
try
{
LocationTModel oLocation = _locationService.GetByEmployeeID(employeeID).ConvertToTModel();
return Ok(oLocation);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
}
}
}