58 lines
1.2 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|