public IActionResult Add() { ViewData["Title"] = "Add Customer"; ViewData["resident"] = resident.Get().data.Where(x => x.IsActive == true).Select(x => new SelectListItem() { Value = x.ResidentID.ToString(), Text = x.ResidentName }).ToList(); return(PartialView("_Add", new CustomerViewModel())); }
public async Task <IActionResult> IndexAsync(TransactionViewModel model) { if (model.TrxDate.Year == 1) { model.TrxDate = DateTime.Now; } var getRespon = await trxRepo.GetTransaction(model.TrxDate, model.ResidentID); if (getRespon.status) { model = getRespon.data; } var items = resident.Get().data.Where(x => x.IsActive == true).Select(x => new SelectListItem() { Value = x.ResidentID.ToString(), Text = x.ResidentName }).ToList(); items.Insert(0, new SelectListItem() { Text = "All", Value = "0" }); ViewData["resident"] = items; ViewData["Title"] = "Transaction"; return(View(model)); }
public IActionResult GetData(JqueryDatatableParam param) { var dataResident = repo.Get().data; if (!string.IsNullOrEmpty(param.sSearch)) { dataResident = dataResident.Where( x => x.ResidentName.ToLower().Contains(param.sSearch.ToLower()) || x.ResidentNumber.ToLower().Contains(param.sSearch.ToLower()) ).ToList(); } var sortColumnIndex = Convert.ToInt32(HttpContext.Request.Query["iSortCol_0"]); var sortDirection = HttpContext.Request.Query["sSortDir_0"]; Func <ResidentViewModel, string> orderingFunction = e => sortColumnIndex == 3 ? (e.IsActive ? "Enable" : "Disable") : sortColumnIndex == 2 ? e.ResidentName : sortColumnIndex == 1 ? e.ResidentNumber : e.ResidentID.ToString(); dataResident = sortDirection == "asc" ? dataResident.OrderBy(orderingFunction).ToList() : dataResident.OrderByDescending(orderingFunction).ToList(); var displayResult = dataResident.Skip(param.iDisplayStart) .Take(param.iDisplayLength).ToList(); var totalRecords = dataResident.Count(); return(Json(new { param.sEcho, iTotalRecords = totalRecords, iTotalDisplayRecords = totalRecords, Data = displayResult })); }