Beispiel #1
0
        public ActionResult GetList(JQueryDataTableParamModel param)
        {
            PartnerService PartnerService = new PartnerService();

            var allPartners = PartnerService.GetAllExposeDto();

            IEnumerable<PartnerDto> filteredPartners;

            if (!string.IsNullOrEmpty(param.sSearch))
            {
                //Used if particulare columns are filtered
                var PartnerIdFilter = Convert.ToString(Request["sSearch_2"]);
                var PartnerNameFilter = Convert.ToString(Request["sSearch_3"]);

                //Optionally check whether the columns are searchable at all
                var isPartnerIdSearchable = Convert.ToBoolean(Request["bSearchable_2"]);
                var isPartnerNameSearchable = Convert.ToBoolean(Request["bSearchable_3"]);

                filteredPartners = allPartners
                   .Where(c => isPartnerIdSearchable && c.PartnerId != null && c.PartnerId.ToLower().Contains(param.sSearch.ToLower())
                            || isPartnerNameSearchable && c.PartnerName != null && c.PartnerName.ToLower().Contains(param.sSearch.ToLower()));
            }
            else
            {
                filteredPartners = allPartners;
            }

            var isPartnerIdSortable = Convert.ToBoolean(Request["bSortable_1"]);
            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            Func<PartnerDto, string> orderingFunction = (c => sortColumnIndex == 1 && isPartnerIdSortable ? c.PartnerId.ToString() :
                                                          "");

            var sortDirection = Request["sSortDir_0"]; // asc or desc
            if (sortDirection == "asc")
                filteredPartners = filteredPartners.OrderBy(orderingFunction);
            else
                filteredPartners = filteredPartners.OrderByDescending(orderingFunction);

            IEnumerable<PartnerDto> displayedPartners;

            if (param.iDisplayLength != -1)
                displayedPartners = filteredPartners.Skip(param.iDisplayStart).Take(param.iDisplayLength);
            else
                displayedPartners = filteredPartners;

            var result = from c in displayedPartners
                         select new[]
                              {
                                  c.Id.ToString(),
                                  c.IsActive,
                                  c.PartnerId,
                                  c.PartnerName,
                                  c.AddressLine1,
                                  c.AddressLine2,
                                  c.City,
                                  c.State,
                                  c.Postcode,
                                  c.Contact,
                                  c.Phone,
                                  c.Fax,
                                  c.SupplierNo
                              };
            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = allPartners.Count(),
                iTotalDisplayRecords = filteredPartners.Count(),
                aaData = result
            },
                        JsonRequestBehavior.AllowGet);
        }
        public ActionResult Index()
        {
            ClientService clientService = new ClientService();
            PartnerService partnerService = new PartnerService();

            ClientPartnerModel model = new ClientPartnerModel();
            model.Clients = clientService.GetAllExposeDto().ToList();
            model.Partners = partnerService.GetAllExposeDto().ToList();
            return View(model);
        }