public IActionResult LoadLoanDisbursementTableData() { var draw = Request.Form["draw"].FirstOrDefault(); var start = Request.Form["start"].FirstOrDefault(); var length = Request.Form["length"].FirstOrDefault(); var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault(); var sortColumnDir = Request.Form["order[0][dir]"].FirstOrDefault(); var searchValue = Request.Form["search[value]"].FirstOrDefault(); int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; var AllLoans = (from loanDisbursement in db.LoanDisbursement.GetAll() join loanApplication in db.LoanApplication.GetAll() on loanDisbursement.LoanApplicationId equals loanApplication.Id into Mixed from finalLoanApplication in Mixed.DefaultIfEmpty() join employee in db.Employee.GetAll() on finalLoanApplication.ApplierId equals employee.Id into EmployeeMixed from finalEmployee in EmployeeMixed.DefaultIfEmpty() select new { finalEmployee.FullName, loanDisbursement.DisbursementAmount, loanDisbursement.ApprovedAmount, loanDisbursement.Id, loanDisbursement.LoanApplicationId, finalLoanApplication.Reason, finalLoanApplication.ApplierId, }).ToList(); //var AllLoans = db.Loan.GetAll().Where(d => d.IsActive == true && d.IsDeleted == false); List <vmLoan> LoanList = new List <vmLoan>(); //Sorting if (!string.IsNullOrEmpty(sortColumn) && !string.IsNullOrEmpty(sortColumnDir)) { // AllLoans = AllLoans.AsQueryable().OrderBy(sortColumn + " " + sortColumnDir).ToList(); } else { AllLoans = AllLoans.OrderByDescending(model => model.Id).ToList(); } //Search if (!string.IsNullOrEmpty(searchValue)) { AllLoans = AllLoans.Where(model => model.FullName.Contains(searchValue) || model.Reason.Contains(searchValue) || model.ApprovedAmount == Convert.ToInt32(searchValue) || model.DisbursementAmount == Convert.ToInt32(searchValue)).ToList(); } //total number of rows count recordsTotal = AllLoans.Count(); //Paging var data = AllLoans.Skip(skip).Take(pageSize).ToList(); //Returning Json Data return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data })); }
public IActionResult LoadEmployeeTask() { var draw = Request.Form["draw"].FirstOrDefault(); var start = Request.Form["start"].FirstOrDefault(); var length = Request.Form["length"].FirstOrDefault(); var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault(); var sortColumnDir = Request.Form["order[0][dir]"].FirstOrDefault(); var searchValue = Request.Form["search[value]"].FirstOrDefault(); int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; var loggedInEmployeeId = User.GetCurrentEmployeeId(db.Employee); var employeeTask = (from employeeTaskName in db.EmployeeTask.GetAll() join employeeName in db.Employee.GetAll() on employeeTaskName.AssignToId equals employeeName.Id into Mixed from finalEmployeeTask in Mixed.DefaultIfEmpty() where employeeTaskName.AssigneeId == loggedInEmployeeId select new { employeeTaskName.Id, finalEmployeeTask.FullName, employeeTaskName.Responsibility, employeeTaskName.DueDate, employeeTaskName.AssignToId, employeeTaskName.AssigneeId, employeeTaskName.Replay, employeeTaskName.Marks, employeeTaskName.Comments, }).ToList(); List <vmEmployeeTask> employeeTaskList = new List <vmEmployeeTask>(); foreach (var items in employeeTask) { vmEmployeeTask get = new vmEmployeeTask { Id = items.Id, FullName = items.FullName, Responsibility = items.Responsibility, DueDate = items.DueDate.Date, AssigneeId = items.AssigneeId, AssignToId = items.AssignToId, Reply = items.Replay, Comments = items.Comments, Marks = items.Marks, ChangeDueDate = items.DueDate.ToString("dddd dd MMMMM yyyy") }; employeeTaskList.Add(get); } //Sorting if (!string.IsNullOrEmpty(sortColumn) && !string.IsNullOrEmpty(sortColumnDir)) { // AllLoans = AllLoans.AsQueryable().OrderBy(sortColumn + " " + sortColumnDir).ToList(); } else { employeeTask = employeeTask.OrderByDescending(model => model.FullName).ToList(); } //Search if (!string.IsNullOrEmpty(searchValue)) { employeeTask = employeeTask.Where(model => model.FullName.Contains(searchValue)).ToList(); } //total number of rows count recordsTotal = employeeTask.Count(); //Paging var data = employeeTask.Skip(skip).Take(pageSize).ToList(); //Returning Json Data return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = employeeTaskList })); }