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 _logger; private Iexternal_employeeService _repository; #endregion #region Properties #endregion /// /// Default constructure for dependency injection /// /// /// public external_employeeController(ILogger logger, Iexternal_employeeService repository) { _logger = logger; _repository = repository; } /// /// Get list items by employee_type, position_type /// /// /// /// Return list of items by specifced keyword /// Returns the item /// Error Occurred [HttpGet("")] [ProducesResponseType(typeof(List), 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}"); } } /// /// Get Blank Item /// /// /// /// Return a blank item /// Returns the item /// Error Occurred [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}"); } } /// /// GetLeaveOfEmployee /// /// /// /// Return list of items by specifced keyword /// Returns the item /// Error Occurred [HttpGet("GetLeaveOfEmployee")] [ProducesResponseType(typeof(List), 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}"); } } } }