126 lines
4.1 KiB
C#
126 lines
4.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.Extensions.Logging;
|
|
using TTSW.Controllers;
|
|
using TTSW.EF;
|
|
using TTSW.Utils;
|
|
using TTSW.Constant;
|
|
using TTSW.Common;
|
|
using TodoAPI2.Models;
|
|
using System.Data;
|
|
|
|
namespace TodoAPI2.Controllers
|
|
{
|
|
//[Authorize]
|
|
[Produces("application/json")]
|
|
[Route("api/external_employee")]
|
|
public class external_employeeController : BaseController
|
|
{
|
|
#region Private Variables
|
|
private ILogger<external_employeeController> _logger;
|
|
private Iexternal_employeeService _repository;
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// Default constructure for dependency injection
|
|
/// </summary>
|
|
/// <param name="repository"></param>
|
|
/// <param name="logger"></param>
|
|
public external_employeeController(ILogger<external_employeeController> logger, Iexternal_employeeService repository)
|
|
{
|
|
_logger = logger;
|
|
_repository = repository;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Get list items by employee_type, position_type
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// </remarks>
|
|
/// <returns>Return list of items by specifced keyword</returns>
|
|
/// <response code="200">Returns the item</response>
|
|
/// <response code="500">Error Occurred</response>
|
|
[HttpGet("")]
|
|
[ProducesResponseType(typeof(List<external_employeeViewModel>), 200)]
|
|
[ProducesResponseType(400)]
|
|
[ProducesResponseType(500)]
|
|
//[ValidateAntiForgeryToken]
|
|
public IActionResult GetList(int? employee_type, int? position_type)
|
|
{
|
|
try
|
|
{
|
|
return Ok(_repository.GetListByemployee_type(employee_type, position_type));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogCritical($"Exception while get list of items.", ex);
|
|
return StatusCode(500, $"Exception while get list of items. {ex.Message}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get Blank Item
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// </remarks>
|
|
/// <returns>Return a blank item</returns>
|
|
/// <response code="200">Returns the item</response>
|
|
/// <response code="500">Error Occurred</response>
|
|
[HttpGet("GetBlankItem")]
|
|
[ProducesResponseType(typeof(external_employeeWithSelectionViewModel), 200)]
|
|
[ProducesResponseType(400)]
|
|
[ProducesResponseType(500)]
|
|
//[ValidateAntiForgeryToken]
|
|
public IActionResult GetBlankItem()
|
|
{
|
|
try
|
|
{
|
|
var result = _repository.GetBlankItem();
|
|
|
|
return Ok(result);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogCritical($"Exception while get specific item.", ex);
|
|
return StatusCode(500, $"Exception while get specific item. {ex.Message}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// GetLeaveOfEmployee
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// </remarks>
|
|
/// <returns>Return list of items by specifced keyword</returns>
|
|
/// <response code="200">Returns the item</response>
|
|
/// <response code="500">Error Occurred</response>
|
|
[HttpGet("GetLeaveOfEmployee")]
|
|
[ProducesResponseType(typeof(List<employee_leaveViewModel>), 200)]
|
|
[ProducesResponseType(400)]
|
|
[ProducesResponseType(500)]
|
|
//[ValidateAntiForgeryToken]
|
|
public IActionResult GetLeaveOfEmployee(int employee_id, DateTime? start_date, DateTime? end_date)
|
|
{
|
|
try
|
|
{
|
|
return Ok(_repository.GetLeaveOfEmployee(employee_id, start_date, end_date));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogCritical($"Exception while get list of items.", ex);
|
|
return StatusCode(500, $"Exception while get list of items. {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|