170 lines
5.3 KiB
C#
170 lines
5.3 KiB
C#
|
|
using HRM.BO;
|
|||
|
|
using HRM.BO.Configuration;
|
|||
|
|
using HRM.DA;
|
|||
|
|
using HRM.Service;
|
|||
|
|
using Microsoft.AspNetCore.Authorization;
|
|||
|
|
using Microsoft.AspNetCore.Http;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
using Microsoft.Extensions.Configuration;
|
|||
|
|
using Microsoft.Extensions.Options;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.IO;
|
|||
|
|
|
|||
|
|
namespace HRM.UI.Controllers
|
|||
|
|
{
|
|||
|
|
[ApiController]
|
|||
|
|
[Route("api/LongServiceAward")]
|
|||
|
|
[Authorize]
|
|||
|
|
public class LongServiceAwardController : Controller
|
|||
|
|
{
|
|||
|
|
#region Declaration
|
|||
|
|
private readonly ILongServiceAwardService _longServiceAwardService;
|
|||
|
|
|
|||
|
|
public LongServiceAwardController(ILongServiceAwardService longServiceAwardService)
|
|||
|
|
{
|
|||
|
|
this._longServiceAwardService = longServiceAwardService;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
[Route("getLongServiceAward")]
|
|||
|
|
public ActionResult getLongServiceAward()
|
|||
|
|
{
|
|||
|
|
List<LongServiceAwardMaster> olist = new List<LongServiceAwardMaster>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
olist = _longServiceAwardService.Get();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(olist);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
[Route("getLongServiceAwardByDateRange/{fromDate}/{toDate}")]
|
|||
|
|
public ActionResult GetLongServiceAwardByDateRange(DateTime fromDate, DateTime toDate)
|
|||
|
|
{
|
|||
|
|
List<LongServiceAwardMaster> olist = new List<LongServiceAwardMaster>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
olist = _longServiceAwardService.GetByDateRange(fromDate, toDate);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(olist);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("saveLongServiceAward")]
|
|||
|
|
public ActionResult SaveLongServiceAward(LongServiceAwardMaster item)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
MailSender oMailSender = new MailSender();
|
|||
|
|
EmailSettings emailSettings = new EmailSettings();
|
|||
|
|
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
|
|||
|
|
IConfiguration Configuration = builder.Build();
|
|||
|
|
Configuration.GetSection("EmailSettings").Bind(emailSettings);
|
|||
|
|
|
|||
|
|
if (item.IsNew == true)
|
|||
|
|
{
|
|||
|
|
item.CreatedBy = currentUser.UserID;
|
|||
|
|
item.CreatedDate = DateTime.Today;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
item.ModifiedBy = currentUser.UserID;
|
|||
|
|
item.ModifiedDate = DateTime.Today;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_longServiceAwardService.SaveLongServiceAward(item);
|
|||
|
|
|
|||
|
|
if(item.AwardStatus==EnumAwardStatus.SentToLMForReview )
|
|||
|
|
{
|
|||
|
|
_longServiceAwardService.SendMail(item, oMailSender, emailSettings);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("saveLongServiceAwardList")]
|
|||
|
|
public ActionResult SaveLongServiceAwardList(List<LongServiceAwardMaster> items)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
foreach (LongServiceAwardMaster item in items)
|
|||
|
|
{
|
|||
|
|
if (item.IsNew == true)
|
|||
|
|
{
|
|||
|
|
item.CreatedBy = currentUser.UserID;
|
|||
|
|
item.CreatedDate = DateTime.Today;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
item.ModifiedBy = currentUser.UserID;
|
|||
|
|
item.ModifiedDate = DateTime.Today;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_longServiceAwardService.SaveLongServiceAward(item);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return Ok();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("deleteLongServiceAward")]
|
|||
|
|
public ActionResult DeleteLongServiceAward(LongServiceAwardMaster item)
|
|||
|
|
{
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
_longServiceAwardService.DeleteLongServiceAward(item);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
[Route("getEmployeeDataforLongServiceAward/{timeRange}/{awardDate}")]
|
|||
|
|
public ActionResult GetEmployeeDataforLongServiceAward(int timeRange, DateTime awardDate)
|
|||
|
|
{
|
|||
|
|
DataTable dt = new DataTable();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
dt = _longServiceAwardService.GetEmployeeDataforLongServiceAward(timeRange, awardDate);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(dt);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|