public ActionResult <Api <Object> > CountSalary(Date countingDate) { int page = 1; int limit = 10; int totalItems = _employeeService.CountAll(); int totalPages = (int)Math.Ceiling((double)totalItems / limit); string massage = SystemContant.SALARY_COUNTING_FIELD_DETAIL_MASSAGE; bool isErr = false; if (countingDate.day == 0) { countingDate.day = DateTime.Today.Day; } if (countingDate.month > DateTime.Today.Month || countingDate.year > DateTime.Today.Year) { throw new Exception(SalaryMessageContant.OVER_TIME); } //if (!_salaryService.CanCounting(new DateTime(countingDate.year, countingDate.month, countingDate.day))) // return Ok(new Api<string>(200, "", SystemContant.SALARY_COUNTING_FIELD_MASSAGE)); for (int i = page; i <= totalPages; i++) { List <EmployeeDTO> employees = _employeeService.FindAll(i, limit); foreach (EmployeeDTO emp in employees) { if (!_salaryService.DoSalaryCounting(emp.Id, countingDate)) { isErr = true; massage += " " + emp.Id + ":" + emp.Lastname + emp.Firstname + " - "; } } } if (!isErr) { return(Ok(new Api <Object>((int)HttpStatusCode.OK, null, SystemContant.SALARY_COUNTING_SUCCSESS_MASSAGE))); } return(Ok(new Api <Object>((int)HttpStatusCode.InternalServerError, null, massage))); }