public IActionResult GetList(DataTableAjaxPostModel param)
        {
            int recordsTotal = 0;
            var result       = _voucherReasonCategoryMasterRepository.GetList().Where(x => x.ClientId == clientId).ToList();

            if (result.Any())
            {
                recordsTotal = result.Count;
                if (param.status == Helper.Active)
                {
                    result = result.Where(x => x.Status).ToList();
                }
                else if (param.status == Helper.Inactive)
                {
                    result = result.Where(x => !x.Status).ToList();
                }

                if (!string.IsNullOrEmpty(param.search.value))
                {
                    var search = param.search.value;
                    result = result.Where(x => x.Name.ToLower().Contains(search.ToLower())).ToList();
                }
            }

            string order    = Convert.ToString(param.order[0].column);
            string orderDir = param.order[0].dir;

            switch (order)
            {
            case "0":
                result = orderDir.Equals("DESC", StringComparison.CurrentCultureIgnoreCase) ? result.OrderByDescending(p => p.Name).ToList() : result.OrderBy(p => p.Name).ToList();
                break;

            default:
                result = result.OrderByDescending(p => p.Id).ToList();
                break;
            }

            var data = result;

            if (param.length > 0)
            {
                data = result.Skip(param.start).Take(param.length).ToList();
            }

            return(Json(new
            {
                draw = param.draw,
                recordsFiltered = result.Count,
                recordsTotal = recordsTotal,
                data = data
            }));
        }
コード例 #2
0
 public IActionResult Index(int Id = 0)
 {
     if (hasVoucherIssuancePermission)
     {
         var voucherIssuance = new VoucherIssuance_VM();
         categories           = _voucherReasonCategoryMasterRepository.GetList().Where(x => x.ClientId == clientId && x.Status).ToList();
         ViewBag.CategoryList = new SelectList(categories, "Id", "Name");
         ViewBag.VoucherList  = new SelectList(_voucherSetupRepository.GetVoucherForIssuance(loginUserId), "Id", "Name");
         ViewBag.CustomerList = new SelectList(_customersRespository.GetCustomersByClient(clientId), "Id", "FirstName");
         if (Id > 0)
         {
             voucherIssuance = _voucherIssuanceRepository.Get(Id, this.loginUserId, isAdmin);
             if (voucherIssuance == null)
             {
                 return(RedirectToAction("List", "VoucherIssuance"));
             }
             else
             {
                 subCategories           = _voucherReasonSubCategoryMasterRepository.GetList().Where(x => x.ReasonCategoryId == voucherIssuance.ReasonCategoryId && x.ClientId == clientId).ToList();
                 ViewBag.SubCategoryList = new SelectList(subCategories, "Id", "Name");
                 ViewData["Title"]       = "Edit";
                 return(View(voucherIssuance));
             }
         }
         else
         {
             if (categories.Any())
             {
                 subCategories = _voucherReasonSubCategoryMasterRepository.GetList().Where(x => x.ReasonCategoryId == categories[0].Id && x.ClientId == clientId).ToList();
             }
             ViewBag.SubCategoryList = new SelectList(subCategories, "Id", "Name");
             ViewData["Title"]       = "Add";
             return(View(voucherIssuance));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Dashboard"));
     }
 }
        public IActionResult Index(int Id = 0)
        {
            ViewBag.ReasonCategories = new SelectList(_voucherReasonCategoryMasterRepository.GetList().Where(x => x.ClientId == clientId && x.Status), "Id", "Name");
            var subcategory = new ReasonSubCategoryMaster_VM();

            if (Id > 0)
            {
                subcategory = _voucherReasonSubCategoryMasterRepository.Get(Id);
                if (subcategory == null)
                {
                    return(RedirectToAction("List", " VoucherReasonSubCategory"));
                }
                else
                {
                    ViewData["Title"] = "Edit";
                    return(View(subcategory));
                }
            }
            else
            {
                ViewData["Title"] = "Add";
                return(View(subcategory));
            }
        }