public IList <Statistic> GetDepartmentStatistics(GetDepartmentStatistics model) { var list = new List <Statistic>(); 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 s in _dbContext.Statistics on e.Id equals s.EmployeeId where e.DepartmentId == DepartmentId && e.IsDelete == false orderby s.Year descending, s.Month descending, e.Id ascending select new Statistic { EmployeeId = e.Id, Month = s.Month, Year = s.Year, FullName = e.FullName, Punctual = s.Punctual, Late = s.Late, Unauthorized = s.Unauthorized, PaidLeave = s.PaidLeave, UnpaidLeave = s.UnpaidLeave, DaysLeaveRemaining = s.DaysLeaveRemaining }).ToList(); } catch (Exception ex) { throw ex; } return(list); }
public IActionResult DepartmentStatistics() { var model = new GetDepartmentStatistics() { ManagerId = 1 }; var responseData = _managerRepository.GetDepartmentStatistics(model); return(Json(new { response = responseData, code = 1 })); }