EchoTex_Payroll/HRM.UI/Controllers/Attendance/AttendanceController.cs

3497 lines
127 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using Ease.Core.DataAccess;
using HRM.BO;
using HRM.BO.Configuration;
using HRM.DA;
using HRM.UI.MODELS;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using Microsoft.EntityFrameworkCore.ValueGeneration.Internal;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using static iTextSharp.text.pdf.AcroFields;
namespace HRM.UI.Controllers.Attendance
{
[Route("api/Attendance")]
[ApiController]
[Authorize]
public class AttendanceController : ControllerBase
{
private readonly IShiftService _shiftService;
private readonly IHolidayCalendarService _holidayCalendarService;
private readonly IAttnNationalHolidayService _attnNationalHolidayService;
private readonly IWorkPlanGroupService _workPlanGroupService;
private readonly IEmployeeWorkPlanSetupService _employeeWorkPlanSetupService;
private readonly IShiftRotationService _shiftRotationService;
private readonly IDailyAttnProcessService _dailyAttnProcessService;
private readonly IActingResponsibilitySetupService _actingResponsibilitySetupService;
private readonly IEmployeeOutsideDutyService _employeeOutsideDutyService;
private readonly IMonthlyWorkPlanService _monthyWorkPlan;
private readonly IActingResponsibilitySetupService _actingResponsiblity;
private readonly IAttnRawDataService _attnRawDataService;
private readonly IEmployeeService _employeeService;
private readonly IPayrollComponentListService _payrollComponentListService;
private readonly IAllowanceDeductionService _allowanceDeductionService;
private readonly ITermService _termService;
private readonly IOutsideDutyService _outsideDutyService;
private readonly IOptions<EmailSettings> _emailSettings;
private readonly ILeaveYearService _leaveYearService;
private readonly IAccessCardService _accessCardService;
private readonly ICardOperationService _cCardOperationService;
public AttendanceController(IShiftService shiftService,
IHolidayCalendarService holidayCalendarService,
IAttnNationalHolidayService attnNationalHolidayService,
IWorkPlanGroupService workPlanGroupService,
IEmployeeWorkPlanSetupService employeeWorkPlanSetupService,
IShiftRotationService shiftRotationService,
IDailyAttnProcessService dailyAttnProcessService,
IEmployeeOutsideDutyService employeeOutsideDutyService,
IMonthlyWorkPlanService monthyworkplan,
IActingResponsibilitySetupService actingResponsiblity,
IEmployeeService employeeService,
IAttnRawDataService attnRawDataService,
IActingResponsibilitySetupService actingResponsibilitySetupService,
IPayrollComponentListService payrollComponentListService,
IAllowanceDeductionService allowanceDeductionService,
ITermService termService,
IOutsideDutyService outsideDutyService,
IOptions<EmailSettings> emailSettings,
ILeaveYearService leaveYearService,
IAccessCardService oaccessCardService,
ICardOperationService ocCardOperationService)
{
this._shiftService = shiftService;
this._holidayCalendarService = holidayCalendarService;
this._attnNationalHolidayService = attnNationalHolidayService;
this._workPlanGroupService = workPlanGroupService;
this._employeeWorkPlanSetupService = employeeWorkPlanSetupService;
this._shiftRotationService = shiftRotationService;
this._dailyAttnProcessService = dailyAttnProcessService;
this._employeeOutsideDutyService = employeeOutsideDutyService;
this._monthyWorkPlan = monthyworkplan;
this._actingResponsiblity = actingResponsiblity;
this._attnRawDataService = attnRawDataService;
this._employeeService = employeeService;
this._actingResponsibilitySetupService = actingResponsibilitySetupService;
this._payrollComponentListService = payrollComponentListService;
this._allowanceDeductionService = allowanceDeductionService;
this._termService = termService;
this._outsideDutyService = outsideDutyService;
this._emailSettings = emailSettings;
this._leaveYearService = leaveYearService;
this._accessCardService = oaccessCardService;
this._cCardOperationService = ocCardOperationService;
}
// SHIFT
[HttpGet("getShifts/{code}/{name}/{status}")]
public ActionResult GetShifts(string code, string name, EnumStatus status)
{
code = GlobalFunctions.GetApiDefaultData(code);
name = GlobalFunctions.GetApiDefaultData(name);
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<Shift> items = new List<Shift>();
try
{
items = _shiftService.Get(code, name, status, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getShiftById/{id}")]
public ActionResult GetShiftById(int id)
{
Shift item = new Shift();
try
{
item = _shiftService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getShiftByName/{name}")]
public ActionResult GetShiftByName(string name)
{
Shift item = new Shift();
try
{
item = _shiftService.Get(name);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getOutSideDutyTypes")]
public ActionResult GetOutSideDutyTypes()
{
List<OutsideDuty> oOutsideDuty = new List<OutsideDuty>();
try
{
oOutsideDuty = _outsideDutyService.Get(EnumStatus.Active);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(oOutsideDuty);
}
[HttpGet("getAttendanceAllowancePrev")]
public ActionResult GetAttendanceAllowancePrev()
{
List<PayrollComponentList> componenentList = new List<PayrollComponentList>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
List<enumPayrollComponentType> ptipes = new List<enumPayrollComponentType>();
ptipes.Add(enumPayrollComponentType.Over_Time);
ptipes.Add(enumPayrollComponentType.Allowance);
componenentList = _payrollComponentListService.Get(ptipes, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(componenentList);
}
[HttpGet("getAttendanceAllowance")]
public ActionResult GetAttendanceAllowance()
{
List<AllowanceDeduction> oAllowanceDeduction = new List<AllowanceDeduction>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
oAllowanceDeduction = _allowanceDeductionService.Get(EnumStatus.Active, EnumAllowOrDeduct.Allowance, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(oAllowanceDeduction);
}
[HttpGet("getAttendanceOverTimeAllowance")]
public ActionResult GetAttendanceOverTimeAllowance()
{
List<Term> oTerm = new List<Term>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
oTerm = _termService.Get(EnumStatus.Active, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(oTerm);
}
[HttpGet("getShiftByCounterClock/{isCounterClock}")]
public ActionResult GetShiftByCounterClock(bool isCounterClock)
{
List<Shift> items = new List<Shift>();
try
{
items = _shiftService.Get(isCounterClock);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("isShiftExist/{shiftCode}/{shortName}/{shiftId}")]
public ActionResult IsShiftExist(string shiftCode, string shortName, int shiftId)
{
bool ans;
try
{
ans = _shiftService.IsExist(shiftCode, shortName, shiftId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpPost]
[Route("deleteShiftById")]
public ActionResult DeleteShiftById(Shift oshift)
{
try
{
_shiftService.Delete(oshift.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveTemporaryShift")]
public ActionResult SaveTemporaryShift(UpdateRosterModel oUpdateRosterModel)
{
try
{
_actingResponsibilitySetupService.SaveTemporaryShift(oUpdateRosterModel);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveShift")]
public ActionResult SaveShift(Shift item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
item.Status = EnumStatus.Active;
item.payrollTypeID = (int)currentUser.PayrollTypeID;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
try
{
_shiftService.Save(item);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
// Holiday Calendar
[HttpGet("getHolidaysByLocId/{locId}")]
public ActionResult GetHolidaysByLocId(int locId)
{
List<HolidayCalendar> items = new List<HolidayCalendar>();
try
{
items = _holidayCalendarService.GetHoliDays(locId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost("ProcessHoliday")]
public ActionResult ProcessHoliday(HolidayCalendar Item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
_holidayCalendarService.Process((int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(true);
}
[HttpGet("getNationalHolidays")]
public ActionResult GetNationalHolidays()
{
List<HolidayCalendar> items = new List<HolidayCalendar>();
try
{
items = _holidayCalendarService.GetNationalHolidays();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getHolidayById/{id}")]
public ActionResult GetHolidayById(int id)
{
HolidayCalendar item = new HolidayCalendar();
try
{
item = _holidayCalendarService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getTotalMonthlyHolidays/{locationNumber}/{firstDateOfMonth}/{lastDateOfMonth}")]
public ActionResult GetTotalMonthlyHolidays(int locationNumber, DateTime firstDateOfMonth,
DateTime lastDateOfMonth)
{
int ans;
try
{
ans = _holidayCalendarService.GetTotalMonthlyHolidays(locationNumber, firstDateOfMonth,
lastDateOfMonth);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpGet("getAllHolidays")]
public ActionResult GetAllHolidays()
{
List<HolidayCalendar> items = new List<HolidayCalendar>();
try
{
items = _holidayCalendarService.Get();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getWeeklyHolidays")]
public ActionResult GetWeeklyHolidays()
{
List<HolidayCalendar> items = new List<HolidayCalendar>();
try
{
items = _holidayCalendarService.GetWeeklyHoliDay();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getWeeklyAndLocHoliday/{locId}")]
public ActionResult GetWeeklyAndLocHoliday(int locId)
{
List<HolidayCalendar> items = new List<HolidayCalendar>();
try
{
items = _holidayCalendarService.GetWeeklyAndLocHoliday(locId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getNoOfHoliday")]
public ActionResult GetNoOfHoliday()
{
double ans;
try
{
ans = _holidayCalendarService.GetNoofHoliday();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpGet("getHolidaysByMonthRange/{locationId}/{startDate}/{endDate}")]
public ActionResult GetHolidaysByMonthRange(int locationId, DateTime startDate, DateTime endDate)
{
List<HolidayCalendar> items = new List<HolidayCalendar>();
try
{
items = _holidayCalendarService.GetbyMonthRange(locationId, startDate, endDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getHolidaysByDateRange/{startDate}/{endDate}")]
public ActionResult GetHolidaysByDateRange(DateTime startDate, DateTime endDate)
{
List<HolidayCalendar> items = new List<HolidayCalendar>();
try
{
items = _holidayCalendarService.GetbyDateRange(startDate, endDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost]
[Route("saveHoliday")]
public ActionResult SaveHoliday(HolidayCalendar item)
{
try
{
_holidayCalendarService.Save(item);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteHolidayById")]
public ActionResult DeleteHolidayById(int id)
{
try
{
_holidayCalendarService.Delete(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteAllHolidayByYear")]
public ActionResult DeleteAllHolidayByYear(int year)
{
try
{
_holidayCalendarService.DeleteAll(year);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
// AttnNationalHoliday
[HttpGet("getAttnNationalHolidayById/{id}")]
public ActionResult GetAttnNationalHolidayById(int id)
{
AttnNationalHoliday item = new AttnNationalHoliday();
try
{
item = _attnNationalHolidayService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getupcommingNationalHoliday/{fromDate}")]
public ActionResult getupcommingNationalHoliday(string fromDate)
{
List<AttnNationalHoliday> items = new List<AttnNationalHoliday>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
//int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
items = _attnNationalHolidayService.GetupcommintHolidayByUserId(fdate, (int)currentUser.PayrollTypeID);
//items = _attnNationalHolidayService.GetupcommintHoliday(new DateTime(2021,1,1), payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnNationalHolidayListByDateRange/{fromDate}/{toDate}")]
public ActionResult GetAttnNationalHolidayListByDateRange(DateTime fromDate, DateTime toDate)
{
List<AttnNationalHoliday> items = new List<AttnNationalHoliday>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
items = _attnNationalHolidayService.Get(fromDate, toDate, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnNationalHolidayListByStatus/{status}")]
public ActionResult GetAttnNationalHolidayListByStatus(EnumStatus status)
{
List<AttnNationalHoliday> items = new List<AttnNationalHoliday>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
LeaveYear oLeaveyear = _leaveYearService.GetCurrentYear((int)currentUser.PayrollTypeID);
items = _attnNationalHolidayService.GetByMonthAndPayrollTypeWithDetails(oLeaveyear.StartDate, oLeaveyear.EndDate, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnNationalHolidayLocationList/{id}")]
public ActionResult getAttnNationalHolidayLocationList(int id)
{
List<AttnNationalHolidayLocation> items = new List<AttnNationalHolidayLocation>();
try
{
items = _attnNationalHolidayService.GetAttnNationalHolidayLocation(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnNationalHolidayShiftList/{id}")]
public ActionResult GetAttnNationalHolidayShiftList(int id)
{
List<AttnShiftWiseNationalHoliday> items = new List<AttnShiftWiseNationalHoliday>();
try
{
items = _attnNationalHolidayService.GetAttnNationalHolidayShift(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnNationalHolidayListByMonthAndPayrollType/{fromDate}/{toDate}")]
public ActionResult GetAttnNationalHolidayListByMonthAndPayrollType(DateTime fromDate, DateTime toDate)
{
List<AttnNationalHoliday> items = new List<AttnNationalHoliday>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
items = _attnNationalHolidayService.GetByMonthAndPayrollType(fromDate, toDate, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost]
[Route("deleteAttnNationalHolidayById")]
public ActionResult DeleteAttnNationalHolidayById(AttnNationalHoliday nationalHoliday)
{
try
{
_attnNationalHolidayService.Delete(nationalHoliday.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveAttnNationalHoliday")]
public ActionResult SaveAttnNationalHoliday(AttnNationalHoliday item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
int ans;
try
{
ans = _attnNationalHolidayService.Save(item, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
// WorkPlanGroup
[HttpGet("getWorkPlanGroupById/{id}")]
public ActionResult GetWorkPlanGroupById(int id)
{
WorkPlanGroup item = new WorkPlanGroup();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
item = _workPlanGroupService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("GetWorkPlanGroups/{status}/{Name}/{Type}")]
public ActionResult GetWorkPlanGroups(EnumStatus status, string name, string groupType)
{
EnumWorkPlanGroup? gType = null;
if (GlobalFunctions.GetApiDefaultIntData(groupType) != null)
gType = (EnumWorkPlanGroup)GlobalFunctions.GetApiDefaultIntData(groupType);
name = GlobalFunctions.GetApiDefaultData(name);
List<WorkPlanGroup> items = new List<WorkPlanGroup>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
items = _workPlanGroupService.Get(status, (int)currentUser.PayrollTypeID, name, gType);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
//[HttpGet("getWorkPlanGroupListByName/{name}")]
//public ActionResult GetWorkPlanGroupListByName(string name)
//{
// List<WorkPlanGroup> items = new List<WorkPlanGroup>();
// CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
// int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
// try
// {
// items = _workPlanGroupService.GetByName(name, payrollTypeId);
// }
// catch (Exception e)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
// }
// return Ok(items);
//}
[HttpGet("getAllWorkPlanGroupList")]
public ActionResult GetAllWorkPlanGroupList()
{
List<WorkPlanGroup> items = new List<WorkPlanGroup>();
try
{
items = _workPlanGroupService.GetAll();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost]
[Route("saveWorkPlanGroup")]
public ActionResult SaveWorkPlanGroup(WorkPlanGroup item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
if (item.IsNew == true)
{
item.CreatedDate = DateTime.Today;
item.CreatedBy = currentUser.UserID;
item.PayrollTypeID = item.PayrollTypeID;
}
else
{
item.ModifiedDate = DateTime.Today;
item.CreatedBy = currentUser.UserID;
}
int ans;
try
{
ans = _workPlanGroupService.Save(item, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpPost]
[Route("deleteWorkPlanGroupById")]
public ActionResult DeleteWorkPlanGroupById(WorkPlanGroup item)
{
try
{
_workPlanGroupService.Delete(item.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
// EmployeeWorkPlanSetup
[HttpGet("getEmployeeWorkPlanSetupById/{id}")]
public ActionResult GetEmployeeWorkPlanSetupById(int id)
{
EmployeeWorkPlanSetup item = new EmployeeWorkPlanSetup();
try
{
item = _employeeWorkPlanSetupService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getEmployeeWorkPlanSetupByEmpId/{empId}")]
public ActionResult GetEmployeeWorkPlanSetupByEmpId(int empId)
{
EmployeeWorkPlanSetup item = new EmployeeWorkPlanSetup();
try
{
item = _employeeWorkPlanSetupService.Get(empId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getEmployeeWorkPlanSetupList")]
public ActionResult GetEmployeeWorkPlanSetupList(int empId)
{
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
try
{
items = _employeeWorkPlanSetupService.Get();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost("IsEmpExistInWorkplan")]
public ActionResult IsEmpExistInWorkplan(List<SearchEmployee> empworkPlans)
{
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
items = _employeeWorkPlanSetupService.IsEmpExistInWorkplan(empworkPlans,
(int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getEmployeeWorkPlanSetupByWorkPlanGroup/{type}")]
public ActionResult GetEmployeeWorkPlanSetupByWorkPlanGroup(EnumWorkPlanGroup type)
{
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
try
{
items = _employeeWorkPlanSetupService.Get(type);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getEmployeeWorkPlanSetupForFixedWP/{groupId}/{holiday}")]
public ActionResult GetEmployeeWorkPlanSetupForFixedWP(int groupId, DayOfWeek holiday)
{
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
try
{
items = _employeeWorkPlanSetupService.GetForFixedWP(groupId, holiday);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getNotYetAssiged")]
public ActionResult getNotYetAssiged()
{
//List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
List<Employee> items = new List<Employee>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
//items = _employeeWorkPlanSetupService.NotYetAssigned((int)currentUser.PayrollTypeID);
items = _employeeService.NotYetAssigned((int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getEmployeeWorkPlanSetupByWPGroupID/{groupId}")]
public ActionResult GetEmployeeWorkPlanSetupByWPGroupID(int groupId)
{
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
try
{
items = _employeeWorkPlanSetupService.GetByWPGroupID(groupId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("isEmployeeExistInWorkPlan/{empId}")]
public ActionResult isEmployeeExistInWorkPlan(int empId)
{
bool ans;
try
{
ans = _employeeWorkPlanSetupService.IsEmployeeExistInWorkplan(empId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpGet("isEmployeeWorkPlanSetupExist/{groupId}/{weekendOn}")]
public ActionResult IsEmployeeWorkPlanSetupExist(int groupId, DayOfWeek weekendOn)
{
bool ans;
try
{
ans = _employeeWorkPlanSetupService.IsExist(groupId, weekendOn);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpGet("getEmployeeWorkPlanSetupByPayrollTypeID")]
public ActionResult GetEmployeeWorkPlanSetupByWPGroupID()
{
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
items = _employeeWorkPlanSetupService.GetByPayrollTypeID(payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAllEmployeeWorkPlanSetup")]
public ActionResult GetAllEmployeeWorkPlanSetup()
{
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
try
{
items = _employeeWorkPlanSetupService.GetAll();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost]
[Route("saveEmployeeWorkPlanSetup")]
public ActionResult SaveEmployeeWorkPlanSetup(EmployeeWorkPlanSetup item)
{
int ans;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
ans = _employeeWorkPlanSetupService.Save(item, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpPost]
[Route("saveEmployeeWorkPlanSetupList")]
public ActionResult SaveEmployeeWorkPlanSetupList(List<EmployeeWorkPlanSetup> EmployeeWorkPlanSetups)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
int loggedInId = currentUser.UserID;
try
{
foreach (EmployeeWorkPlanSetup employeeWorkPlanSetup in EmployeeWorkPlanSetups)
{
if (employeeWorkPlanSetup.WorkPlanGroupType != EnumWorkPlanGroup.Fixed)
{
DateTime targetDate = employeeWorkPlanSetup.StartDate.AddDays(6);
int nShiftInterval = 7;
TimeSpan st = targetDate - employeeWorkPlanSetup.StartDate;
int dayCount = st.Days;
int nCircleDay = (dayCount % nShiftInterval);
int dayCycle = nShiftInterval - nCircleDay - 1;
if (dayCycle == 0)
employeeWorkPlanSetup.WeekEndOn = employeeWorkPlanSetup.StartDate.DayOfWeek;
else
employeeWorkPlanSetup.WeekEndOn = null;
}
}
EmployeeWorkPlanSetups.ForEach(x => x.CreatedBy = loggedInId);
_employeeWorkPlanSetupService.Save(EmployeeWorkPlanSetups, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveFixedWPlansList")]
public ActionResult SaveFixedWPlansList(List<EmployeeWorkPlanSetup> items)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
_employeeWorkPlanSetupService.SaveFixedWPlans(items, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteEmployeeWorkPlanSetupById")]
public ActionResult DleteEmployeeWorkPlanSetupById(EmployeeWorkPlanSetup item)
{
try
{
_employeeWorkPlanSetupService.Delete(item.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteEmployeeWorkPlanSetupByGroupId")]
public ActionResult DeleteEmployeeWorkPlanSetupByGroupId(EmployeeWorkPlanSetup item)
{
try
{
_employeeWorkPlanSetupService.Delete(item.WorkPlanGroupID, DayOfWeek.Saturday);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
// ShiftRotation
[HttpGet("getShiftRotationById/{id}")]
public ActionResult GetShiftRotationById(int id)
{
ShiftRotation item = new ShiftRotation();
try
{
item = _shiftRotationService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getShiftRotationByWorkPlanGroupType/{workPlanGroupType}")]
public ActionResult GetShiftRotationByWorkPlanGroupType(EnumWorkPlanGroup workPlanGroupType)
{
List<ShiftRotation> items = new List<ShiftRotation>();
try
{
items = _shiftRotationService.Get(workPlanGroupType);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getShiftRotationByWorkPlanGroup/{workPlanGroup}")]
public ActionResult GetShiftRotationByWorkPlanGroup(EnumWorkPlanGroup workPlanGroup)
{
List<ShiftRotation> items = new List<ShiftRotation>();
try
{
items = _shiftRotationService.Get(workPlanGroup);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getShiftRotationByStatus/{status}")]
public ActionResult GetShiftRotationByStatus(EnumStatus status)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<ShiftRotation> items = new List<ShiftRotation>();
try
{
items = _shiftRotationService.Get(status, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getShiftRotationByWorkGroupType/{workPlanGroupType}/{sequence}")]
public ActionResult GetShiftRotationByWorkGroupType(EnumWorkPlanGroup workPlanGroup, int sequence)
{
ShiftRotation item = new ShiftRotation();
try
{
item = _shiftRotationService.Get(workPlanGroup, sequence);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpPost]
[Route("saveShiftRotation")]
public ActionResult SaveShiftRotation(ShiftRotation item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
_shiftRotationService.Save(item);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteShiftRotationById")]
public ActionResult DeleteShiftRotationById(ShiftRotation item)
{
try
{
_shiftRotationService.Delete(item.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost("getDailyAttnProcessByEmp")]
public ActionResult getDailyAttnProcessByEmp(dynamic data)
{
List<DailyAttnProcess> attnProcesses = new List<DailyAttnProcess>();
try
{
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string empids = "";
DateTime attnDate = DateTime.Today;
foreach (var item in items)
{
int empID = (int)item["employeeid"].ToObject<int>();
empids = empids + empID.ToString() + ",";
attnDate = (DateTime)item["attnDate"].ToObject<DateTime>();
}
if (empids.Length > 0)
{
empids = empids.Substring(0, empids.Length - 1);
}
attnDate = new DateTime(attnDate.Year, attnDate.Month, attnDate.Day);
attnProcesses = this._dailyAttnProcessService.Get(empids, attnDate, attnDate);
// removed by shamim, please talk to him if needed this
//foreach(DailyAttnProcess process in attnProcesses)
//{
// process.ActualInOutTime = (process.ActualInTime == null ? (process.InTime == null ? "" : process.InTime.Value.ToString("hh:mm tt")) : process.ActualInTime.Value.ToString("hh:mm tt") )+ " - " + (process.ActualOutTime == null ? (process.OutTime == null ? "" : process.OutTime.Value.ToString("hh:mm tt")) : process.ActualOutTime.Value.ToString("hh:mm tt"));
//}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(attnProcesses);
}
// DailyAttnProcess
[HttpGet("getDailyAttnProcessByEmployeeId/{employeeId}")]
public ActionResult GetDailyAttnProcessByEmployeeId(int employeeId)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.GetByEmployeeID(employeeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getMonthJobCardByEmployeeId/{employeeId}/{attnMonth}")]
public ActionResult GetMonthJobCardByEmployeeId(int employeeId, string attnMonth)
{
JobCardReport jobCardReport = null;
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
DateTime dateTime = Convert.ToDateTime(attnMonth);
jobCardReport = _dailyAttnProcessService.GetMonthJobCardByEmployeeId(employeeId,
dateTime.FirstDateOfMonth(), dateTime.LastDateOfMonth(), payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(jobCardReport);
}
[HttpGet("getMonthJobCardNewByEmployeeId/{employeeId}/{attnMonth}")]
public ActionResult GetMonthJobCardNewByEmployeeId(int employeeId, string attnMonth)
{
byte[] bytes = null;
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
DateTime dateTime = Convert.ToDateTime(attnMonth);
//jobCardReport = _dailyAttnProcessService.GetMonthJobCardNewByEmployeeId(employeeId,
//dateTime.FirstDateOfMonth(), dateTime.LastDateOfMonth(), payrollTypeId);
bytes = new HRM.Report.AttendanceReport().ShowDateRangeJobCardMultiple(dateTime.FirstDateOfMonth(), dateTime.LastDateOfMonth(),
employeeId.ToString(), payrollTypeId, "EXCEL");
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(bytes);
}
//[HttpGet("getDailyDataByStatusReport/{attnDate}/{sStatus}/{sEmpID}")]
//public ActionResult GetDailyDataByStatusReport(DateTime attnDate, string sStatus, string sEmpID)
//{
// List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
// try
// {
// DateTime dateTime = Convert.ToDateTime(attnDate);
// dailyAttnByStatusReports = _dailyAttnProcessService.GetDailyDataByStatusReport(attnDate,
// sStatus, sEmpID);
// }
// catch (Exception e)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
// }
// return Ok(dailyAttnByStatusReports);
//}
[HttpPost("getDateRangeWiseDataByStatusReport")]
public ActionResult GetDateRangeWiseDataByStatusReport(dynamic data)
{
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string sEmpID = (string)items["empIds"].ToObject<string>();
DateTime fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
DateTime toDate = (DateTime)items["toDate"].ToObject<DateTime>();
string sStatus = (string)items["status"].ToObject<string>();
try
{
dailyAttnByStatusReports = _dailyAttnProcessService.GetDateRangeWiseDataByStatusReport(fromDate, toDate,
sStatus, sEmpID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(dailyAttnByStatusReports);
}
[HttpPost("getDailyDataByStatusReport")]
public ActionResult GetDailyDataByStatusReport(dynamic data)
{
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string sEmpID = (string)items["empIds"].ToObject<string>();
DateTime attnDate = (DateTime)items["attnDate"].ToObject<DateTime>();
string sStatus = (string)items["status"].ToObject<string>();
try
{
dailyAttnByStatusReports = _dailyAttnProcessService.GetDailyDataByStatusReport(attnDate,
sStatus, sEmpID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(dailyAttnByStatusReports);
}
[HttpPost("getDataByStatusReport")]
public ActionResult GetDataByStatusReport(dynamic data)
{
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string sEmpID = (string)items["empIds"].ToObject<string>();
DateTime fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
DateTime toDate = (DateTime)items["toDate"].ToObject<DateTime>();
string sStatus = (string)items["status"].ToObject<string>();
try
{
dailyAttnByStatusReports = _dailyAttnProcessService.GetDataByStatusReport(fromDate, toDate,
sStatus, sEmpID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(dailyAttnByStatusReports);
}
[HttpPost("getDailyOddDataByStatusReport")]
public ActionResult GetDailyOddDataByStatusReport(dynamic data)
{
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string sEmpID = (string)items["empIds"].ToObject<string>();
DateTime attnDate = (DateTime)items["attnDate"].ToObject<DateTime>();
try
{
dailyAttnByStatusReports = _dailyAttnProcessService.GetDailyOddDataByStatusReport(attnDate,
sEmpID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(dailyAttnByStatusReports);
}
[HttpPost("getDateWiseAttnRecords")]
public ActionResult GetDateWiseAttnRecords(dynamic data)
{
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string sEmpID = (string)items["empIds"].ToObject<string>();
DateTime attnDate = (DateTime)items["attnDate"].ToObject<DateTime>();
try
{
dailyAttnByStatusReports = _dailyAttnProcessService.GetDateWiseAttnRecords(attnDate,
sEmpID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(dailyAttnByStatusReports);
}
[HttpPost("getDailyAttnProcessByWFStatus")]
public ActionResult GetDailyAttnProcessByWFStatus(dynamic data)
{
List<DailyAttnProcess> dailyAttnProcess = new List<DailyAttnProcess>();
List<AttendanceRegularizationDTO> attendanceRegularizationDTOs = new List<AttendanceRegularizationDTO>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string sEmpID = (string)items["empIds"].ToObject<string>();
DateTime fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
DateTime toDate = (DateTime)items["toDate"].ToObject<DateTime>();
EnumWFAttnStatus status = (EnumWFAttnStatus)Convert.ToInt16(items["status"].ToObject<string>());
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (string.IsNullOrEmpty(sEmpID) || sEmpID == "0")
{
sEmpID = currentUser.EmployeeID.ToString();
}
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
dailyAttnProcess = _dailyAttnProcessService.GetAttnDataByWFStatus(fromDate, toDate, sEmpID, status);
attendanceRegularizationDTOs =
AttendanceProcess.GetNotSubmittedAttnData(dailyAttnProcess, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(attendanceRegularizationDTOs);
}
[HttpGet("getMyNotSubmittedAbsentList")]
public ActionResult getMyNotSubmittedAbsentList()
{
List<DailyAttnProcess> dailyAttnProcess = new List<DailyAttnProcess>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
dailyAttnProcess = _dailyAttnProcessService.getMyNotSubmittedAbsentList((int)currentUser.EmployeeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(dailyAttnProcess);
}
[HttpGet("getMyTeamNotApprovedList")]
public ActionResult getMyTeamNotApprovedList()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
DataTable olist = null;
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
olist = _dailyAttnProcessService.getMyTeamNotApprovedList((int)currentUser.EmployeeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(olist);
}
[HttpGet("getMyTeamAbsentAndLeaveList/{frommonth}/{tomonth}")]
public ActionResult getMyTeamAbsentAndLeaveList(string frommonth, string tomonth)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
DataTable olist = null;
DateTime ddate = Convert.ToDateTime(frommonth);
DateTime dtomonth = Convert.ToDateTime(tomonth);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
olist = _dailyAttnProcessService.getMyTeamAbsentAndLeaveList((int)currentUser.EmployeeID
, GlobalFunctions.FirstDateOfMonth(ddate), GlobalFunctions.LastDateOfMonth(dtomonth));
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(olist);
}
[HttpPost("getDailyAttnProcessByEmpIdandWFStatus")]
public ActionResult GetDailyAttnProcessByEmpIdandWFStatus(dynamic data)
{
List<DailyAttnProcess> dailyAttnProcess = new List<DailyAttnProcess>();
List<AttendanceRegularizationDTO> attendanceRegularizationDTOs = new List<AttendanceRegularizationDTO>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string sEmpID = (string)items["empIds"].ToObject<string>();
EnumWFAttnStatus status = (EnumWFAttnStatus)Convert.ToInt16(items["status"].ToObject<string>());
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (string.IsNullOrEmpty(sEmpID) || sEmpID == "0")
{
sEmpID = currentUser.EmployeeID.ToString();
}
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
dailyAttnProcess = _dailyAttnProcessService.GetAttnDataByWFStatus(sEmpID, status);
attendanceRegularizationDTOs =
AttendanceProcess.GetNotSubmittedAttnData(dailyAttnProcess, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(attendanceRegularizationDTOs);
}
[HttpPost("updateAttendanceRegularization")]
public ActionResult UpdateAttendanceRegularization(DailyAttnProcess pDailyAttnProcess)
{
List<DailyAttnProcess> regularizableAttnData = new List<DailyAttnProcess>();
regularizableAttnData.Add(pDailyAttnProcess);
try
{
_dailyAttnProcessService.Save(regularizableAttnData, null);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
Thread CheckOutFixedPositionThread = new Thread(() =>
_dailyAttnProcessService.SendRegularizationApplicationMail(pDailyAttnProcess, _emailSettings.Value));
CheckOutFixedPositionThread.Start();
//try
//{
// // send mail to LM
// _dailyAttnProcessService.SendRegularizationApplicationMail(pDailyAttnProcess, _emailSettings.Value);
//}
//catch (Exception e)
//{
// return StatusCode(StatusCodes.Status500InternalServerError, "Successfully Regularized. But could not send mail.");
//}
return Ok();
}
[HttpPost("updateAttendanceRegularizationForApprove")]
public ActionResult UpdateAttendanceRegularizationForApprove(DailyAttnProcess item)
{
if (item == null)
{
return StatusCode(StatusCodes.Status500InternalServerError, "No Data Found to save");
}
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.LineManagerID = (int)currentUser.EmployeeID;
item.LMApproveDate = DateTime.Today;
if (item.ShiftID != null)
{
Shift oshift = new ShiftService().Get((int)item.ShiftID);
if (oshift != null)
{
new AttendanceProcess().CalculateLateAndDelay(item, oshift);
new AttendanceProcess().CalculateOverTime(item, oshift);
}
}
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
items.Add(item);
try
{
this._dailyAttnProcessService.ApproveAttnByLM(item);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
try
{
// send mail to Applier
_dailyAttnProcessService.SendRegularizationApprovalMail(item, _emailSettings.Value);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, "Successfully Regularized. But could not send mail.");
}
return Ok();
}
[HttpPost("updateActingResponsibilitySetupForApprove")]
public ActionResult UpdateActingResponsibilitySetupForApprove(
ActingResponsibilitySetup actingResponsibilitySetup)
{
if (actingResponsibilitySetup == null)
{
return StatusCode(StatusCodes.Status500InternalServerError, "No Data Found to save");
}
ActingResponsibilitySetup dailyAttnProcess =
_actingResponsibilitySetupService.Get(actingResponsibilitySetup.ID);
if (dailyAttnProcess == null)
{
return StatusCode(StatusCodes.Status500InternalServerError, "No Previous Data Found to save");
}
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
actingResponsibilitySetup.ModifiedBy = currentUser.EmployeeID;
actingResponsibilitySetup.ModifiedDate = DateTime.Today;
_actingResponsibilitySetupService.Save(actingResponsibilitySetup);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet("getLastProcessDateByEmpId/{empId}")]
public ActionResult GetLastProcessDateByEmpId(int empId)
{
DateTime item;
try
{
item = _dailyAttnProcessService.GetLastProcessDateByEmpId(empId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getAttnSubmittedDataByDateRange/{empId}/{fromDate}/{toDate}")]
public ActionResult GetAttnSubmittedDataByDateRange(string empId, DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.GetAttnSubmittedData(empId, fromDate, toDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnSubmittedData/{empId}/{isCurrentMonth}")]
public ActionResult GetAttnSubmittedData(string empId, bool isCurrentMonth)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.GetAttnSubmittedData(empId, isCurrentMonth);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnDataByWFStatus/{empId}/{status}")]
public ActionResult GetAttnDataByWFStatus(string empId, EnumWFAttnStatus status)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.GetAttnDataByWFStatus(empId, status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnDataByWFStatusCount/{empId}/{status}")]
public ActionResult GetAttnDataByWFStatusCount(string empId, EnumWFAttnStatus status)
{
int ans;
try
{
ans = _dailyAttnProcessService.GetAttnDataByWFStatusCount(empId, status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpGet("getDailyAttnProcessById/{id}")]
public ActionResult GetDailyAttnProcessById(int id)
{
DailyAttnProcess item = new DailyAttnProcess();
try
{
item = _dailyAttnProcessService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getDailyAttnProcessByEmpId/{empId}/{attnDate}")]
public ActionResult GetDailyAttnProcessByEmpId(int empId, DateTime attnDate)
{
DailyAttnProcess item = new DailyAttnProcess();
try
{
item = _dailyAttnProcessService.Get(empId, attnDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getDailyAttnProcessByWPG/{wpg}/{attnDate}")]
public ActionResult GetDailyAttnProcessByWPG(EnumWorkPlanGroup wpg, DateTime attnDate)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.GetProcessByWPG(wpg, attnDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDailyAttnProcessByAttnDate/{attnDate}")]
public ActionResult GetDailyAttnProcessByAttnDate(DateTime attnDate)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
items = _dailyAttnProcessService.Get(attnDate, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDailyAttnManualProcess/{attnDate}")]
public ActionResult GetDailyAttnManualProcess(DateTime attnDate)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.GetManualProcess(attnDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
//internal static IDataReader GetTeamForAttenReguApprove(TransactionContext tc, int employeeid, EnumStatus enumStatus)
//{
// return tc.ExecuteReader(@"SELECT DISTINCT e.EmployeeID, EmployeeNo, e.Name, e.categoryID, e.GradeID,
// LocationID, d.name as DesignationName, g.DESCRIPTION GradeName, dept.DESCRIPTION DepartmentName From Employee e
// left join designation d on d.DESIGNATIONID = e.DESIGNATIONID
// LEFT JOIN DEPARTMENT dept ON dept.DEPARTMENTID = e.DEPARTMENTID
// LEFT JOIN GRADES g ON g.GRADEID = e.GRADEID
// LEFT JOIN DAILYATTNPROCESS dap ON dap.EMPLOYEEID = e.EMPLOYEEID
// WHERE dap.WFStatus = 1 AND e.linemanagerid =%n and e.status = %n", employeeid, (int)enumStatus);
//}
[HttpGet("getDailyAttnProcessByEmpIdAndDateRange/{empId}/{sFromDate}/{sToDate}")]
public ActionResult GetDailyAttnProcessByEmpIdAndDateRange(int empId, string sFromDate, string sToDate)
{
List<AttendanceRegularizationDTO> attendanceRegularizationDTOs = new List<AttendanceRegularizationDTO>();
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
if (empId == 0)
{
empId = (int)currentUser.EmployeeID;
}
try
{
DateTime fromDate = Convert.ToDateTime(sFromDate);
DateTime toDate = Convert.ToDateTime(sToDate);
dailyAttnProcesses = _dailyAttnProcessService.Get(empId, fromDate, toDate);
attendanceRegularizationDTOs =
AttendanceProcess.GetNotSubmittedAttnData(dailyAttnProcesses, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(attendanceRegularizationDTOs);
}
[HttpGet("getDailyAttnProcessByDateRangeEss/{empId}/{sFromDate}/{sToDate}")]
public ActionResult GetDailyAttnProcessByDateRangeEss(int empId, string sFromDate, string sToDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
if (empId == 0)
{
empId = (int)currentUser.EmployeeID;
}
try
{
DateTime fromDate = Convert.ToDateTime(sFromDate);
DateTime toDate = Convert.ToDateTime(sToDate);
dailyAttnProcesses = _dailyAttnProcessService.Get(empId, fromDate, toDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(dailyAttnProcesses);
}
[HttpGet("getRegularizableAttendance/{empId}/{sFromDate}/{sToDate}")]
public ActionResult getRegularizableAttendance(int empId, string sFromDate, string sToDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
if (empId == 0)
{
empId = (int)currentUser.EmployeeID;
}
try
{
DateTime fromDate = Convert.ToDateTime(sFromDate);
DateTime toDate = Convert.ToDateTime(sToDate);
dailyAttnProcesses = _dailyAttnProcessService.GetRegularizableAttn(empId, fromDate, toDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(dailyAttnProcesses);
}
[HttpGet("getDailyAttnProcessBysEmpIdAndDateRange/{empId}/{fromDate}/{toDate}")]
public ActionResult GetDailyAttnProcessBysEmpIdAndDateRange(string empId, string fromDate, string toDate)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
DateTime dfromDate = GlobalFunctions.GetApiDefaultDateData(fromDate);
DateTime dtoDate = GlobalFunctions.GetApiDefaultDateData(toDate);
try
{
items = _dailyAttnProcessService.Get(Convert.ToInt32(empId), dfromDate, dtoDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDailyAttnProcessByDateRange/{fromDate}/{toDate}")]
public ActionResult GetDailyAttnProcessByDateRange(DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.Get(fromDate, toDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDailyAttnProcessByAttnDateAndShiftId/{attnDate}/{shiftId}/{attnType}")]
public ActionResult GetDailyAttnProcessByAttnDateAndShiftId(DateTime attnDate, int shiftId,
EnumAttendanceType attnType)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.Get(attnDate, shiftId, attnType);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDailyEmployeeAbsentById/{id}/{date}")]
public ActionResult GetDailyEmployeeAbsentById(int id, DateTime date)
{
DailyAttnProcess item = new DailyAttnProcess();
try
{
item = _dailyAttnProcessService.GetDailyEmployeeAbsent(id, date);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getDailyAttnWhereOutTimeIsNull/{attnDate}/{shiftId}")]
public ActionResult GetDailyAttnWhereOutTimeIsNull(DateTime attnDate, int shiftId)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.GetWhrOutTimeIsNull(attnDate, shiftId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getEmployeesFirstAttendances/{employeeIds}")]
public ActionResult getEmployeesFirstAttendances(string employeeIds)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.GetEmployeesFirstAttendances(employeeIds);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getLastProcessDate")]
public ActionResult GetLastProcessDate()
{
DateTime item = new DateTime();
try
{
item = _dailyAttnProcessService.GetLastProcessDate();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet(
"getDailyAttnProcessByEmpIdAndShiftIdAndDateRange/{empId}/{shiftId}/{fromDate}/{toDate}/{attendanceType}")]
public ActionResult GetDailyAttnProcessByEmpIdAndShiftIdAndDateRange(int empId, int shiftId, DateTime fromDate,
DateTime toDate, EnumAttendanceType attendanceType)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.Get(empId, shiftId, fromDate, toDate, attendanceType);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDailyAttnProcessByAttnDateAndEmpIds/{attnDate}/{empIds}")]
public ActionResult GetDailyAttnProcessByAttnDateAndEmpIds(DateTime attnDate, string empIds)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
items = _dailyAttnProcessService.Get(attnDate, empIds, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnDataByWFStatusCountByDateRange/{fromDate}/{toDate}/{status}")]
public ActionResult GetAttnDataByWFStatusCountByDateRange(DateTime fromDate, DateTime toDate,
EnumWFAttnStatus status)
{
int ans;
try
{
ans = _dailyAttnProcessService.GetAttnDataByWFStatusCount(fromDate, toDate, status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpGet("getDailyAttnBySalaryMonth/{salaryMonth}")]
public ActionResult GetDailyAttnBySalaryMonth(DateTime salaryMonth)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
items = _dailyAttnProcessService.GetBySalaryMonth(salaryMonth, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDailyAttnByStatusAndDateRange/{empId}/{fromDate}/{toDate}/{status}")]
public ActionResult GetDailyAttnByStatusAndDateRange(int empId, DateTime fromDate, DateTime toDate,
string status)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.GetByStatus(empId, fromDate, toDate, status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDailyAttnByStatusAndDateRangeAndsEmpId/{empId}/{fromDate}/{toDate}/{status}")]
public ActionResult getDailyAttnByStatusAndDateRangeAndsEmpId(string empId, DateTime fromDate, DateTime toDate,
EnumClaimWFStatus status)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
try
{
items = _dailyAttnProcessService.Get(empId, fromDate, toDate, status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getDailyAttnLastProcessDate")]
public ActionResult GetDailyAttnLastProcessDate()
{
DateTime item = new DateTime();
try
{
item = _dailyAttnProcessService.GetLastProcessDate();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet("getDailyAttnManualProcessByAttnDate/{attnDate}")]
public ActionResult GetDailyAttnManualProcessByAttnDate(DateTime attnDate)
{
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
items = _dailyAttnProcessService.GetManualProcess(attnDate, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getAttnDataByWFStatusByProcessId/{dailyAttnProcessId}/{status}")]
public ActionResult GetAttnDataByWFStatusByProcessId(int dailyAttnProcessId, EnumWFAttnStatus status)
{
DailyAttnProcess item = new DailyAttnProcess();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
item = _dailyAttnProcessService.GetAttnDataByWFStatus(dailyAttnProcessId, status);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpPost]
[Route("saveDailyAttnProcess")]
public ActionResult SaveDailyAttnProcess(DailyAttnProcess item)
{
try
{
_dailyAttnProcessService.Save(new List<DailyAttnProcess>() { item }, null);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("RejectAttnStatusByLM")]
public ActionResult RejectAttnStatusByLM(DailyAttnProcess process)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
_dailyAttnProcessService.RejectAttnStatusByLM(process.EmployeeID, process.AttnDate, (int)currentUser.EmployeeID, process.LMRemarks, process.Comments);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
try
{
// send mail to Applier
_dailyAttnProcessService.SendRegularizationApprovalMail(process, _emailSettings.Value);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, "Successfully Regularized. But could not send mail.");
}
return Ok(true);
}
[HttpPost]
[Route("save")]
public ActionResult Save(List<DailyAttnProcess> item)
{
try
{
_dailyAttnProcessService.Save(item, null);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saverawdata")]
public ActionResult SaveRawData(List<AttnRawData> items)
{
try
{
//List<AttnRawData> items = new List<AttnRawData>();
//items = JsonConvert.DeserializeObject<List<AttnRawData>>(data.dataList.ToString());
_attnRawDataService.SaveAuto(items);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet("getrawdata/{fromDate}/{toDate}/{empIDs}")]
public ActionResult GetHolidaysByDateRange(DateTime fromDate, DateTime toDate, string empIDs)
{
empIDs = (empIDs == "null" || empIDs == "undefined") ? null : empIDs;
DateTime end = toDate.AddDays(1).AddSeconds(-1);
List<Employee> employees = new EmployeeService().GetAllEmps();
List<AttnRawData> items = new List<AttnRawData>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
items = _attnRawDataService.Get(fromDate, end, empIDs, (int)currentUser.PayrollTypeID);
foreach (var temp in items)
{
temp.EmployeeName = employees?.Where(x => x.ID == temp.EmployeeID)?.FirstOrDefault()?.Name;
temp.EmployeeNo = employees?.Where(x => x.ID == temp.EmployeeID)?.FirstOrDefault()?.EmployeeNo;
}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
//[HttpPost]
//[Route("saveDailyAttnProcessListWithCounterClock")]
//public ActionResult SaveDailyAttnProcessListWithCounterClock(List<DailyAttnProcess> items)
//{
// try
// {
// _dailyAttnProcessService.Save(items, true);
// }
// catch (Exception e)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
// }
// return Ok();
//}
[HttpPost]
[Route("UpdateManualEntry")]
public ActionResult UpdateManualEntry(List<DailyAttnProcess> items)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<Shift> oshifts = new ShiftService().Get(string.Empty, string.Empty,
EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
foreach (DailyAttnProcess item in items)
{
item.AttnDate = new DateTime(item.AttnDate.Year, item.AttnDate.Month, item.AttnDate.Day);
if (item.InTime != null)
item.InTime = new DateTime(item.AttnDate.Year, item.AttnDate.Month, item.AttnDate.Day,
((DateTime)item.InTime).Hour, ((DateTime)item.InTime).Minute, 0);
if (item.OutTime != null)
{
item.OutTime = new DateTime(item.AttnDate.Year, item.AttnDate.Month, item.AttnDate.Day,
((DateTime)item.OutTime).Hour, ((DateTime)item.OutTime).Minute, 0);
}
if (item.InTime != null && item.OutTime != null)
{
if (((DateTime)item.OutTime).Hour < ((DateTime)item.InTime).Hour)
{
DateTime tempDate = (DateTime)item.AttnDate.AddDays(1);
item.OutTime = new DateTime(tempDate.Year, tempDate.Month, tempDate.Day,
((DateTime)item.OutTime).Hour, ((DateTime)item.OutTime).Minute, 0);
}
}
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
new AttendanceProcess().CalculateLateAndDelay(item, oshifts);
//if(item.ShiftID !=null)
//{ var sft = oshifts.FirstOrDefault(x => x.ID == item.ShiftID);
// if(sft!=null)
// {
// new AttendanceProcess().CalulateOverTimeForMobileAttendance(item, sft);
// }
//}
}
try
{
_dailyAttnProcessService.ManualEditSave(items, (int)currentUser.PayrollTypeID, currentUser.UserID, null);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveDailyAttnProcessList")]
public ActionResult SaveDailyAttnProcessList(List<DailyAttnProcess> items)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<Shift> oshifts = new ShiftService().Get(string.Empty, string.Empty,
EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
foreach (DailyAttnProcess item in items)
{
item.AttnDate = new DateTime(item.AttnDate.Year, item.AttnDate.Month, item.AttnDate.Day);
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
new AttendanceProcess().CalculateLateAndDelay(item, oshifts);
}
try
{
_dailyAttnProcessService.Save(items, null);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveDailyAttnProcessListAndAttnMonthlyBenefits")]
public ActionResult SaveDailyAttnProcessListAndAttnMonthlyBenefits(List<DailyAttnProcess> items)
{
try
{
_dailyAttnProcessService.Save(items, null);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteDailyAttnProcessById")]
public ActionResult DeleteDailyAttnProcessById(DailyAttnProcess item)
{
List<AttnMonthlyBenefit> attnMonthlyBenefits = new List<AttnMonthlyBenefit>();
bool IscounterClock = true;
try
{
_dailyAttnProcessService.Delete(item.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
//[HttpPost]
//[Route("updateLeave")]
//public ActionResult UpdateLeave(DailyAttnProcess item)
//{
// try
// {
// _dailyAttnProcessService.UpdateLeave(item.EmployeeID, 1, DateTime.Now, 1);
// }
// catch (Exception e)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
// }
// return Ok();
//}
//[HttpPost]
//[Route("saveForBridgeHoliday")]
//public ActionResult SaveForBridgeHoliday(List<DailyAttnProcess> items)
//{
// List<LeaveEntry> oLeaveEntrys = new List<LeaveEntry>();
// try
// {
// _dailyAttnProcessService.SaveForBridgeHoliday(items, oLeaveEntrys);
// }
// catch (Exception e)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
// }
// return Ok();
//}
//[HttpPost]
//[Route("saveAutoForLmApproved")]
//public ActionResult SaveAutoForLmApproved(List<DailyAttnProcess> items)
//{
// List<AttnMonthlyBenefit> oAtnMonthlyBenifits = new List<AttnMonthlyBenefit>();
// AttnProcessRunSummary oAttnRunSummary = new AttnProcessRunSummary();
// try
// {
// _dailyAttnProcessService.SaveAutoForLmApproved(items, oAtnMonthlyBenifits, oAttnRunSummary);
// }
// catch (Exception e)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
// }
// return Ok();
//}
[HttpPost]
//[Route("saveAutoDailyAttnProcess")]
//public ActionResult SaveAutoDailyAttnProcess(List<DailyAttnProcess> items)
//{
// List<AttnMonthlyBenefit> oAtnMonthlyBenifits = new List<AttnMonthlyBenefit>();
// AttnProcessRunSummary oAttnRunSummary = new AttnProcessRunSummary();
// try
// {
// _dailyAttnProcessService.SaveAuto(items, oAtnMonthlyBenifits, oAttnRunSummary);
// }
// catch (Exception e)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
// }
// return Ok();
//}
[HttpPost]
[Route("dailyAttnProcessManual")]
public ActionResult dailyAttnProcessManual(dynamic processItems)
{
DateTime fromDate = DateTime.Today;
DateTime toDate = DateTime.Today;
bool withoutEmployee = true;
List<SearchEmployee> emps = null;
List<Employee> employees = null;
int empid;
int count = 0;
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(processItems));
foreach (var item in items)
{
fromDate = (DateTime)item["fromDate"].ToObject<DateTime>();
toDate = (DateTime)item["toDate"].ToObject<DateTime>();
withoutEmployee = (bool)item["isWithEmployee"].ToObject<bool>();
if (withoutEmployee == true) break;
if (withoutEmployee == false && emps == null)
emps = new List<SearchEmployee>();
empid = (int)item["employeeID"].ToObject<int>();
SearchEmployee emp = new SearchEmployee();
emp.EmployeeID = empid;
emps.Add(emp);
}
if (withoutEmployee == false)
{
employees = new EmployeeService().GetByEmpIDs(SearchEmployee.getEmpID(emps),
(int)currentUser.PayrollTypeID);
count++;
}
for (DateTime attDate = fromDate; attDate <= toDate; attDate = attDate.AddDays(1))
{
new AttendanceProcess().Process(new DateTime(attDate.Year, attDate.Month, attDate.Day),
EnumProcessMode.Manual, (int)currentUser.PayrollTypeID, currentUser.UserID, employees);
}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("BenifitProcess")]
public ActionResult BenifitProcess(dynamic processItems)
{
List<SalaryProcessStatus> items = new List<SalaryProcessStatus>();
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
items = new AttendanceProcess().BenifitProcess(currentUser.UserID, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
// EmployeeOutsideDuty
[HttpGet("getAllEmployeeOutsideDuties")]
public ActionResult GetAllEmployeeOutsideDuties()
{
List<EmployeeOutsideDuty> items = new List<EmployeeOutsideDuty>();
try
{
items = _employeeOutsideDutyService.Get();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getOutsideDutiesByEmployeeId/{empId}")]
public ActionResult getOutsideDutiesByEmployeeId(int empId)
{
List<EmployeeOutsideDutyDetails> items = new List<EmployeeOutsideDutyDetails>();
try
{
items = _employeeOutsideDutyService.GetByEmpIdDetails(empId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost]
[Route("saveEmployeeOutsideDuty")]
public ActionResult SaveEmployeeOutsideDuty(EmployeeOutsideDuty item)
{
int ans = 0;
try
{
ans = _employeeOutsideDutyService.Save(item);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpPost]
[Route("SaveMontlhyWorkPlan")]
public ActionResult SaveMontlhyWorkPlan(List<MonthlyWorkPlan> items)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
items.ForEach(x =>
{
x.payrollTypeID = (int)currentUser.PayrollTypeID;
x.CreatedBy = currentUser.UserID;
x.CreatedDate = DateTime.Today;
});
try
{
this._monthyWorkPlan.Save(items);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(true);
}
[HttpGet]
[Route("DeleteMontlhyWorkPlan/{FromDate}/{ToDate}")]
public ActionResult DeleteMontlhyWorkPlan(DateTime fromDate, DateTime toDate)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
this._monthyWorkPlan.Delete(fromDate, toDate, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(true);
}
[HttpGet]
[Route("DeleteOnwardMonthyworkPlan/{fromMonth}")]
public ActionResult DeleteOnwardMonthyworkPlan(DateTime fromMonth)
{
fromMonth = GlobalFunctions.FirstDateOfMonth(fromMonth);
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
this._monthyWorkPlan.DeleteOnward(fromMonth, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(true);
}
[HttpGet]
[Route("GetWorkPlan/{MonthDate}")]
public ActionResult GetWorkPlan(DateTime MonthDate)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<MonthlyWorkPlan> items = null;
try
{
items = this._monthyWorkPlan.Get(MonthDate, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(true);
}
[HttpGet]
[Route("GetWorkPlanByDate/{FromDate}/{toDate}")]
public ActionResult GetWorkPlanByDate(DateTime MonthDate, DateTime toDate)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<MonthlyWorkPlan> items = null;
try
{
items = this._monthyWorkPlan.Get(MonthDate, toDate, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(true);
}
[HttpGet]
[Route("RefreshMonthlyWorkplan/{monthDate}")]
public ActionResult RefreshMonthlyWorkplan(string monthDate)
{
DateTime fdate = GlobalFunctions.FirstDateOfMonth(GlobalFunctions.GetApiDefaultDateData(monthDate));
DateTime tdate = GlobalFunctions.LastDateOfMonth(fdate);
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<MonthlyWorkPlan> items = null;
try
{
items = this._monthyWorkPlan.RefreshMonthlyWorkplan(fdate, tdate, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost]
[Route("UpdateMonthlyWorkplan")]
public ActionResult UpdateMonthlyWorkplan(MonthlyWorkPlan mworkPlan)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
mworkPlan.payrollTypeID = (int)currentUser.PayrollTypeID;
List<MonthlyWorkPlan> items = null;
try
{
this._monthyWorkPlan.UpdateShiftAndRoster(mworkPlan);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost]
[Route("GetRosterTable")]
public ActionResult GetRosterTable(List<MonthlyWorkPlan> monthyPlans)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<WorkPlanGroup> groups = this._workPlanGroupService.Get(EnumStatus.Regardless,
(int)currentUser.PayrollTypeID, string.Empty, null);
List<Shift> oshifts = this._shiftService.Get(string.Empty, string.Empty, EnumStatus.Regardless,
(int)currentUser.PayrollTypeID);
DataTable table = new DataTable("RosterCanlender");
table.Columns.Add("Date");
groups.ForEach(x => { table.Columns.Add(new DataColumn(x.Name)); });
try
{
DateTime fromDAte = monthyPlans[0].WorkDate;
DateTime toDAte = monthyPlans[monthyPlans.Count - 1].WorkDate;
for (DateTime dDate = fromDAte; dDate <= toDAte; dDate = dDate.AddDays(1))
{
DataRow row = table.NewRow();
row["Date"] = dDate.ToString("dd MMM");
table.Rows.Add(row);
}
int nindex = -1;
for (DateTime dDate = fromDAte; dDate <= toDAte; dDate = dDate.AddDays(1))
{
nindex = nindex + 1;
foreach (WorkPlanGroup wg in groups)
{
MonthlyWorkPlan oplan = monthyPlans.FirstOrDefault(x => x.WorkDate == dDate
&& x.WorkPlanGroupID == wg.ID);
if (oplan != null)
{
if (oplan.Type == EnumWorkPlanDayType.WorkingDay)
{
Shift oshift = oshifts.FirstOrDefault(x => x.ID == oplan.ShiftID);
if (oshift != null)
{
table.Rows[nindex][wg.Name] = oshift.ShortName;
}
}
else if (oplan.Type == EnumWorkPlanDayType.WeeklyHoliday)
{
table.Rows[nindex][wg.Name] = "WH";
}
else
{
table.Rows[nindex][wg.Name] = "NH";
}
}
}
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(table);
}
[HttpGet]
[Route("GetLastSavedWorkDate")]
public ActionResult GetLastSavedWorkDate()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
DateTime ddate;
try
{
ddate = this._monthyWorkPlan.GetLastSavedWorkDate((int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
string sdata = "";
if (ddate != DateTime.MinValue)
sdata = ddate.ToString("dd MMM yyyy");
return Ok(sdata);
}
[HttpPost]
[Route("deleteEmployeeOutsideDuty")]
public ActionResult DeleteEmployeeOutsideDuty(EmployeeOutsideDuty item)
{
try
{
_employeeOutsideDutyService.Delete(item.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet]
[Route("getActingResponsiblityByEmpID/{fromDate}/{ToDate}/{empid}")]
public ActionResult getActingResponsiblityByEmpID(string fromDate, string ToDate, int empid)
{
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
DateTime tdate = GlobalFunctions.GetApiDefaultDateData(ToDate);
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<ActingResponsibilitySetup> items = null;
try
{
items = this._actingResponsiblity.GetByEmpID(fdate, tdate, empid);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet]
[Route("getActingResponsiblityByEmpIDAndStatus/{fromDate}/{ToDate}/{empid}/{wfStatus}")]
public ActionResult GetActingResponsiblityByEmpIDAndStatus(string fromDate, string ToDate, int empid,
int wfStatus)
{
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
DateTime tdate = GlobalFunctions.GetApiDefaultDateData(ToDate);
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<ActingResponsibilitySetup> items = null;
try
{
items = this._actingResponsiblity.Get(fdate, tdate, empid, (EnumClaimWFStatus)wfStatus);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet]
[Route("getActingResponsiblityForApprove/{fromDate}/{ToDate}/{wfStatus}")]
public ActionResult GetActingResponsiblityForApprove(string fromDate, string ToDate, int wfStatus)
{
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
DateTime tdate = GlobalFunctions.GetApiDefaultDateData(ToDate);
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<ActingResponsibilitySetup> items = null;
try
{
items = this._actingResponsiblity.GetForApprove(fdate, tdate, (int)currentUser.EmployeeID,
(EnumClaimWFStatus)wfStatus);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet]
[Route("getActingResponsiblity/{fromDate}/{ToDate}")]
public ActionResult getActingResponsiblityByEmpID(string fromDate, string ToDate)
{
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
DateTime tdate = GlobalFunctions.GetApiDefaultDateData(ToDate);
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<ActingResponsibilitySetup> items = null;
try
{
items = this._actingResponsiblity.Get(fdate, tdate, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet]
[Route("getOnWardActingResponsiblity/{fromDate}/{empid}")]
public ActionResult getOnWardActingResponsiblity(string monthFromDate, int empid)
{
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(monthFromDate);
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<ActingResponsibilitySetup> items = null;
try
{
items = this._actingResponsiblity.GetOnwardByEmpID(fdate, empid);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost]
[Route("SaveActingResponsiblities")]
public ActionResult SaveActingResponsiblities(List<ActingResponsibilitySetup> items)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
items.ForEach(item =>
{
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
item.payrollTypeID = (int)currentUser.PayrollTypeID;
item.SalaryMonth = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
});
try
{
this._actingResponsiblity.Save(items);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(true);
}
[HttpPost]
[Route("DeleteActingResponsiblity")]
public ActionResult DeleteActingResponsiblity(ActingResponsibilitySetup item)
{
try
{
this._actingResponsiblity.Delete(item.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("GetEmployeeRoster")]
public dynamic GetEmployeeRoster(dynamic paramData)
{
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(paramData));
string empids = "";
DateTime fromDate = DateTime.Today;
DateTime toDate = DateTime.Today;
bool isteam = false;
foreach (var item in items)
{
int empID = (int)item["employeeID"].ToObject<int>();
if (empID != 0)
empids = empids + empID.ToString() + ",";
fromDate = (DateTime)item["fromDate"].ToObject<DateTime>();
toDate = (DateTime)item["toDate"].ToObject<DateTime>();
isteam = (bool)item["isTeam"].ToObject<bool>();
}
if (empids.Length > 0)
{
empids = empids.Substring(0, empids.Length - 1);
}
DateTime DFromDate = new DateTime(fromDate.Year, fromDate.Month, fromDate.Day);
DateTime DToDate = new DateTime(toDate.Year, toDate.Month, toDate.Day); ;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<SearchEmployee> team = new List<SearchEmployee>();
if (isteam == true)
team = new SearchEmployeeService().GetTeam((int)currentUser.EmployeeID, EnumStatus.Active);
List<MonthlyWorkPlan> mWorkPlans =
this._monthyWorkPlan.Get(DFromDate, DToDate, (int)currentUser.PayrollTypeID);
if (mWorkPlans == null || mWorkPlans.Count == 0)
{
return StatusCode(StatusCodes.Status500InternalServerError, "There is no roster calender, please contact admin user for create roster calender.");
// throw new Exception("There is no roster calender, please contact admin user for create roster calender.");
}
List<WorkPlanGroup> groups = this._workPlanGroupService.Get(EnumStatus.Active,
(int)currentUser.PayrollTypeID, string.Empty, null);
string temp = SearchEmployee.getEmpID(team);
if (empids.Length == 0) empids = temp;
else
{
team.InsertRange(team.Count == 0 ? 0 : team.Count - 1, new SearchEmployeeService().GetByEmpIDIn(empids));
}
if (temp.Length > 0) empids = empids + "," + temp;
if (empids.Length == 0)
{
return StatusCode(StatusCodes.Status500InternalServerError, "employee not found for the roster creation.");
}
List<EmployeeWorkPlanSetup> empworkPlans = this._employeeWorkPlanSetupService.getEmployeeWorkPlan(empids);
List<ActingResponsibilitySetup> actingSetup = this._actingResponsiblity.GetByStatus(DFromDate, DToDate,
(int)currentUser.PayrollTypeID, EnumClaimWFStatus.LMApproved);
List<Shift> oshifts = this._shiftService.Get(string.Empty, string.Empty, EnumStatus.Regardless,
(int)currentUser.PayrollTypeID);
DataTable table = new DataTable("RosterCanlender");
table.Columns.Add("EmployeeID");
table.Columns.Add("Name");
for (DateTime i = DFromDate; i <= DToDate; i = i.AddDays(1))
{
table.Columns.Add(new DataColumn(i.ToString("dd-MMM")));
}
try
{
foreach (SearchEmployee item in team)
{
DataRow row = table.NewRow();
row["EmployeeID"] = item.EmployeeNo;
row["Name"] = item.Name;
table.Rows.Add(row);
for (DateTime i = DFromDate; i <= DToDate; i = i.AddDays(1))
{
EmployeeWorkPlanSetup empworkPlan =
empworkPlans.FirstOrDefault(x => x.EmployeeID == item.EmployeeID);
if (empworkPlan != null)
{
MonthlyWorkPlan mplan = mWorkPlans.FirstOrDefault(x =>
x.WorkDate == i && x.WorkPlanGroupID == empworkPlan.WorkPlanGroupID);
if (mplan != null)
{
var exception = actingSetup.FirstOrDefault(x =>
x.EmployeeID == item.EmployeeID && x.FromDate <= i && i <= x.ToDate);
if (exception != null)
{
if (exception.IsHoliday)
{
row[i.ToString("dd-MMM")] = "WH";
}
else if (exception.ShiftID != null)
{
Shift shift = oshifts.FirstOrDefault(x => x.ID == exception.ShiftID);
if (shift != null) row[i.ToString("dd-MMM")] = "EX-" + shift.ShortName;
}
else
{
MonthlyWorkPlan emplan = mWorkPlans.FirstOrDefault(x =>
x.WorkDate == i && x.WorkPlanGroupID == exception.WorkPlanGroupID);
Shift shift = oshifts.FirstOrDefault(x => x.ID == emplan.ShiftID);
if (shift != null) row[i.ToString("dd-MMM")] = shift.ShortName;
}
}
else
{
if (mplan.Type == EnumWorkPlanDayType.WorkingDay)
{
Shift oshift = oshifts.FirstOrDefault(x => x.ID == mplan.ShiftID);
if (oshift != null)
{
row[i.ToString("dd-MMM")] = oshift.ShortName;
}
}
else if (mplan.Type == EnumWorkPlanDayType.WeeklyHoliday)
{
row[i.ToString("dd-MMM")] = "WH";
}
else
{
row[i.ToString("dd-MMM")] = "NH";
}
}
}
}
}
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(table);
}
#region My Team
[HttpGet]
[Route("getAttendanceDashboard")]
public ActionResult GetAttendanceDashboard()
{
DataTable dt = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int id = currentUser.EmployeeID.GetValueOrDefault();
Employee oEmp = _employeeService.Get(id);
try
{
dt = _dailyAttnProcessService.GetAttendanceDashboard(oEmp);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpGet]
[Route("getTopEmpAbsentData")]
public ActionResult getTopEmpAbsentData()
{
DataTable dt = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int id = currentUser.EmployeeID.GetValueOrDefault();
Employee oEmp = _employeeService.Get(id);
try
{
dt = _dailyAttnProcessService.getTopEmpAbsentData(oEmp, EnumAttendanceType.Absent);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpGet]
[Route("getcorehrAbsentData")]
public ActionResult getcorehrAbsentData()
{
DataTable dt = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int id = currentUser.EmployeeID.GetValueOrDefault();
Employee oEmp = _employeeService.Get(id);
try
{
dt = _dailyAttnProcessService.getcorehrAbsentData(oEmp, EnumAttendanceType.Absent);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
#endregion
[HttpGet("getAccessCard/{id}")]
public ActionResult getAccessCard(int id)
{
AccessCard item = new AccessCard();
try
{
item = this._accessCardService.Get(id);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpPost]
[Route("assignCard")]
public ActionResult assignCard(List<CardOperation> cardOperations)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
AccessCard item = new AccessCard();
cardOperations.ForEach(x =>
{
x.CreatedBy = currentUser.UserID;
x.CreatedDate = DateTime.Today;
});
try
{
this._cCardOperationService.Save(cardOperations, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpPost]
[Route("lostCardFromEmployee")]
public ActionResult lostCardFromEmployee(CardOperation cardOperations)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
AccessCard item = new AccessCard();
try
{
item = new AccessCardService().Get(cardOperations.CardNumber);
cardOperations.CardID = item.ID;
this._cCardOperationService.Save(cardOperations);
new CardOperationService().DetachCardFromEmployee(cardOperations.EmployeeID, cardOperations.CardNumber, cardOperations.AssignDate, EnumCardStatus.Lost);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(item);
}
[HttpGet]
[Route("getCardInformation/{enumCardStatus}")]
public ActionResult getCardInformation(int enumCardStatus)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
DataTable table = null;
try
{
table = new AccessCardService().getCardInformation(enumCardStatus);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(table);
}
[HttpPost]
[Route("foundCard")]
public ActionResult foundCard(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
CardOperation item = new CardOperation();
var ac = new AccessCardService();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string cardNumber = (string)items["cardNumber"].ToObject<string>();
TransactionContext tc = null;
try
{
item = new CardOperationService().Get(cardNumber);
if (item.EmployeeID != 0)
{
throw new Exception("Card is already astteched to another employee");
}
else
{
item.Status = EnumCardStatus.Free;
tc = TransactionContext.Begin(true);
ac.UpdateStatus(tc, item.CardID, item.Status, (int)currentUser.PayrollTypeID);
}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("detachCardInfoFromEmployee")]
public ActionResult detachCardInfoFromEmployee(CardOperation cardOperations)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
TransactionContext tc = null;
var ac = new AccessCardService();
cardOperations.CreatedBy = currentUser.UserID;
cardOperations.CreatedDate = DateTime.Today;
try
{
AccessCard accessCard = new AccessCardService().Get(cardOperations.CardNumber);
cardOperations.CardID = accessCard.ID;
if (cardOperations.CardID != 0)
cardOperations.AccessCard = new AccessCardService().Get(cardOperations.CardID);
tc = TransactionContext.Begin(true);
new CardOperationService().DetachCardFromEmployee(cardOperations.EmployeeID, cardOperations.CardNumber, cardOperations.AssignDate, EnumCardStatus.Detached);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("getAttandanceDashboardData")]
public ActionResult getAttandanceDashboardData(dynamic param)
{
DateTime fromDate = DateTime.Today;
DateTime toDate = DateTime.Today;
int shiftId = 0;
bool isLate = false;
bool isEarly = false;
string departmentIds = string.Empty;
string employeeIds = string.Empty;
bool appliedForRegularize = false;
int status = 0;
string otHourType = string.Empty;
int otHour = 0;
bool isCalledFromEss = false;
string lineManager = string.Empty;
string statusText = string.Empty;
DataTable dt = new DataTable();
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int CurrentUserId = (int)currentUser.EmployeeID;
int payrollTypeId = (int)currentUser.PayrollTypeID;
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(param));
fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
toDate = (DateTime)items["toDate"].ToObject<DateTime>();
shiftId = (int)items["shiftId"].ToObject<int>();
departmentIds = (string)items["departmentIds"].ToObject<string>();
lineManager = (string)items["lineManager"].ToObject<string>();
employeeIds = (string)items["employeeIds"].ToObject<string>();
statusText = (string)items["statusText"].ToObject<string>();
appliedForRegularize = (bool)items["appliedForRegularize"].ToObject<bool>();
status = (int)items["status"].ToObject<int>();
otHourType = (string)items["otHourType"].ToObject<string>();
otHour = (int)items["otHour"].ToObject<int>();
isCalledFromEss = (bool)items["isCalledFromEss"].ToObject<bool>();
dt = new DailyAttnProcessService().GetAttandanceDashboardData(fromDate, toDate, shiftId, departmentIds, employeeIds, appliedForRegularize,
status, otHourType, otHour, CurrentUserId, isCalledFromEss, lineManager, statusText, payrollTypeId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(dt);
}
}
}