Beispiel #1
0
        public virtual ActionResult EditEmployeeLeave(EmployeeLeaveCreateViewModel viewModel)
        {
            var employeeLeave = _employeeLeaveRepository.GetById(viewModel.EmployeeLeaveId);

            _employeeLeaveRepository.Update(employeeLeave);

            employeeLeave.Hours     = viewModel.Hours > 0 ? viewModel.Hours : viewModel.SpecifiedHours;
            employeeLeave.StartDate = viewModel.StartDate;
            employeeLeave.EndDate   = viewModel.EndDate;
            employeeLeave.Reason    = viewModel.Reason;
            employeeLeave.LeaveId   = viewModel.LeaveId;

            if (viewModel.MarkAsApproved)
            {
                employeeLeave.ApprovedBy  = User.Identity.GetUserId();
                employeeLeave.LeaveStatus = LeaveStatus.Approved;
            }
            else
            {
                employeeLeave.LeaveStatus = LeaveStatus.Pending;
            }


            _unitOfWork.Commit();
            _logger.Info(LoggerMessages.INFO_LEAVE_UPDATED, employeeLeave.EmployeeLeaveId, User.Identity.GetUserId());
            return(RedirectToAction("EmployeeLeaves", new { month = DateTime.Now.Month, year = DateTime.Now.Year }));
        }
Beispiel #2
0
        public virtual ActionResult EditEmployeeLeave(int id)
        {
            var leaves = _leaveRepository.Find(x => x.IsActive)
                         .Select(x => new SelectListItem
            {
                Value = x.LeaveId.ToString(),
                Text  = x.LeaveName
            });
            var hours = new List <SelectListItem>
            {
                new SelectListItem
                {
                    Value = "8",
                    Text  = "Whole Day"
                },
                new SelectListItem
                {
                    Value = "4",
                    Text  = "Half Day"
                },
                new SelectListItem
                {
                    Value = "-1",
                    Text  = "Specify Hours"
                }
            };

            var employeeLeave = _employeeLeaveRepository.GetById(id);

            var viewModel = new EmployeeLeaveCreateViewModel
            {
                StartDate       = employeeLeave.StartDate,
                EndDate         = employeeLeave.EndDate,
                Leaves          = leaves,
                MarkAsApproved  = employeeLeave.LeaveStatus == LeaveStatus.Approved,
                LeaveHours      = hours,
                Hours           = employeeLeave.Hours,
                SpecifiedHours  = employeeLeave.Hours,
                EmployeeId      = employeeLeave.EmployeeId,
                EmployeeName    = employeeLeave.Employee.FullName,
                LeaveId         = employeeLeave.LeaveId,
                Reason          = employeeLeave.Reason,
                EmployeeLeaveId = id
            };

            return(View(viewModel));
        }
Beispiel #3
0
        public virtual ActionResult CreateEmployeeLeave(EmployeeLeaveCreateViewModel viewModel)
        {
            var employeeLeave = viewModel.MapItem <EmployeeLeave>();

            employeeLeave.Hours       = viewModel.Hours > 0 ? viewModel.Hours : viewModel.SpecifiedHours;
            employeeLeave.IsActive    = true;
            employeeLeave.LeaveStatus = LeaveStatus.Pending;
            employeeLeave.ApprovedBy  = null;

            if (viewModel.MarkAsApproved)
            {
                employeeLeave.ApprovedBy  = User.Identity.GetUserId();
                employeeLeave.LeaveStatus = LeaveStatus.Approved;
            }


            _employeeLeaveRepository.Add(employeeLeave);
            _unitOfWork.Commit();

            _logger.Info(LoggerMessages.INFO_LEAVE_CREATE, employeeLeave.EmployeeLeaveId, User.Identity.GetUserId());
            return(RedirectToAction("EmployeeLeaves", new { month = DateTime.Now.Month, year = DateTime.Now.Year }));
        }
Beispiel #4
0
        public virtual ActionResult CreateEmployeeLeave()
        {
            var leaves = _leaveRepository.Find(x => x.IsActive)
                         .Select(x => new SelectListItem
            {
                Value = x.LeaveId.ToString(),
                Text  = x.LeaveName
            });
            var hours = new List <SelectListItem>
            {
                new SelectListItem
                {
                    Value = "8",
                    Text  = "Whole Day"
                },
                new SelectListItem
                {
                    Value = "4",
                    Text  = "Half Day"
                },
                new SelectListItem
                {
                    Value = "-1",
                    Text  = "Specify Hours"
                }
            };

            var viewModel = new EmployeeLeaveCreateViewModel
            {
                StartDate  = DateTime.Now.AddDays(1),
                EndDate    = DateTime.Now.AddDays(1),
                Leaves     = leaves,
                LeaveHours = hours
            };

            return(View(viewModel));
        }