public bool AddEmployeeLeaveEntry(LeaveEntry leaveEntry)
        {
            try
            {
                var LeaveConfirmationViewModel = new LeaveConfirmationViewModel
                {
                    EmployeeCode           = leaveEntry.EmployeeCode,
                    LeaveTypeCode          = leaveEntry.LeaveTypeCode,
                    LeaveRequestedFromDate = leaveEntry.LeaveRequestedFromDate.ToString(),
                    LeaveStatus            = leaveEntry.LeaveStatus,
                    NumberOfLeaves         = leaveEntry.NumberOfLeaves
                };
                var result = _leaveStatusService.UpdateEmployeeLeaveAllocation(LeaveConfirmationViewModel);

                if (result == false)
                {
                    return(false);
                }

                _unitOfWork.LeaveEntryRepository.Insert(leaveEntry);
                _unitOfWork.SaveAsync();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public ActionResult LeaveApply(string leaveType, string requestedDate, int?leaveDays, string reason)
        {
            string employeeCode = Session["LoggedEmployeeCode"].ToString();

            if (leaveType != null && requestedDate != null && leaveDays != null && reason != null && leaveType != "" && requestedDate != "" && leaveDays > 0 && reason != "")
            {
                var remainingLeave = _leaveRequestService.GetRemainingLeaveAmountByEmployee(employeeCode, Convert.ToDateTime(requestedDate).Year, leaveType);
                if (remainingLeave == 0)
                {
                    TempData["ErrorMessage"] = "You haven't enough leave !";
                }
                else
                {
                    if (remainingLeave < leaveDays)
                    {
                        TempData["ErrorMessage"] = "Number of days can't be greater than the remaining leave !";
                    }
                    else
                    {
                        var isAlreadyApply = db.LeaveEntry.ToList().Where(a => a.LeaveRequestedFromDate == Convert.ToDateTime(requestedDate)).ToList();

                        if (isAlreadyApply.Count > 0)
                        {
                            TempData["ErrorMessage"] = "You already requested leave on " + requestedDate + " !";
                        }
                        else
                        {
                            var supervisorCode = _leaveRequestService.GetSupervisorCodeByEmployee(employeeCode);
                            var leaveEntry     = new LeaveEntry
                            {
                                EmployeeCode            = employeeCode,
                                LeaveTypeCode           = leaveType,
                                LeaveRequestedFromDate  = Convert.ToDateTime(requestedDate),
                                LeaveRequestedToDate    = Convert.ToDateTime(requestedDate),
                                LeaveStatus             = "Requested",
                                NumberOfLeaves          = (int)leaveDays,
                                EmployeeComment         = reason,
                                EmployeesSupervisorCode = supervisorCode
                            };
                            var result = _leaveRequestService.AddEmployeeLeaveEntry(leaveEntry);

                            if (result == true)
                            {
                                TempData["SuccessMessage"] = "Leave Request send to the supervisor !";
                            }
                            else
                            {
                                TempData["ErrorMessage"] = "Leave Request Error !";
                            }
                        }
                    }
                }
            }
            else
            {
                TempData["ErrorMessage"] = "Please fill all required fields !";
            }
            return(Redirect(this.Request.UrlReferrer.AbsolutePath));
        }
Exemplo n.º 3
0
        private void leaveEntryToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            LeaveEntry obj = new LeaveEntry();

            obj.Show();
        }
Exemplo n.º 4
0
 public bool updateLeaveEntry([FromBody] LeaveEntry loLeaveEntry, string pUserId)
 {
     return(loLeaveEntry.updateLeaveEntry(loLeaveEntry, pUserId));
 }
Exemplo n.º 5
0
 public bool insertLeaveEntry([FromBody] LeaveEntry loLeaveEntry, string pUserId)
 {
     return(loLeaveEntry.insertLeaveEntry(loLeaveEntry, pUserId));
 }