Beispiel #1
0
        public IActionResult DepartmentLeaveApplication()
        {
            var model = new GetDepartmentLeaveApplication()
            {
                ManagerId = 1
            };
            var responseData = _managerRepository.GetDepartmentLeaveApplication(model);

            return(Json(new { response = responseData, code = 1 }));
        }
Beispiel #2
0
        public IList <LeaveApplicationList> GetDepartmentLeaveApplication(GetDepartmentLeaveApplication model)
        {
            var list = new List <LeaveApplicationList>();

            try
            {
                int DepartmentId = _dbContext.Employee.FirstOrDefault(e => e.Id == model.ManagerId && e.IsActive == true && e.IsDelete == false).DepartmentId;

                list = (from e in _dbContext.Employee
                        join l in _dbContext.LeaveApplication on e.Id equals l.EmployeeId
                        where e.DepartmentId == DepartmentId && e.IsDelete == false
                        orderby l.CommentDate descending, l.Id descending
                        select new LeaveApplicationList
                {
                    LeaveApplicationId = l.Id,
                    FullName = e.FullName,
                    Status = l.Status == 1 ? "Chờ" :
                             (l.Status == 2 ? "Chấp nhận" :
                              (l.Status == 3 ? "Từ chối" : ""
                              )),
                    StartDate = l.StartDate.ToString(),
                    EndDate = l.EndDate.ToString(),
                    DaysLeaveRemaining = l.DaysLeaveRemaining,
                    NumberOfAbsent = l.NumberOfAbsent,
                    CommentDate = l.CommentDate.ToString(),
                    FeedbackDate = l.FeedbackDate == null ? "" : l.FeedbackDate.ToString(),
                    Comment = l.Comment,
                    Feedback = l.Feedback,
                    LeaveCode = l.LeaveCode
                }).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(list);
        }