Exemplo n.º 1
0
        public async Task <JsonResult> IndexJson(ListFilterViewModels request)
        {
            var helper = new TransactionTypeDataTableSearchHelper();
            var result = await helper.SearchFunction(request);

            var resultList = (IEnumerable <TransactionTypesViewModel>)result.filteredList;

            var data = resultList.Select(x => new
            {
                Actions = "<div class='btn-group' style='display:flex;'>" +
                          "<a class='btn btn-primary' href='#'><i class='fa fa-gear fa-fw'></i> Action</a>" +
                          "<a class='btn btn-primary dropdown-toggle' data-toggle='dropdown' href='#'>" +
                          "<span class='fa fa-caret-down' title='Toggle dropdown menu'></span>" +
                          "</a>" +
                          "<ul class='dropdown-menu' role='menu'>" +
                          (x.IsActive ? "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Edit") + "' onclick='btnClicked($(this))'><a>Edit</a></li>" : "") +
                          "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Details") + "' onclick='btnClicked($(this))'><a>Details</a></li>" +
                          (x.IsActive ? "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Delete") + "' onclick='btnClicked($(this))'><a>Delete</a></li>" :
                           "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Enable") + "' onclick='btnClicked($(this))'><a>Enable</a></li>") +
                          "</ul>" +
                          "</div>",
                Code      = x.Code,
                TransType = x.TransType,
                IsActive  = x.IsActive
            });

            return(Json(new
            {
                draw = request.draw,
                recordsTotal = result.totalResultCount,
                recordsFiltered = result.filteredResultCount,
                data = data
            }));
        }
Exemplo n.º 2
0
        public async Task <dynamic> SearchFunction(ListFilterViewModels request)
        {
            var list                = new List <VendorViewModel>().AsEnumerable();
            var filteredList        = new List <VendorViewModel>().AsEnumerable();
            int filteredResultCount = 0;
            int totalResultCount    = 0;

            var searchBy = request.search.value?.ToLower() ?? "" ?? "";
            var take     = request.length;
            var skip     = request.start;

            var orderBy  = "Id";
            var orderDir = true;

            if (request.order != null)
            {
                orderDir = request.order[0].dir.ToLower().Equals("asc");
                orderBy  = request.columns[request.order[0].column].data;
                orderBy  = (orderBy.Equals("actions", StringComparison.OrdinalIgnoreCase) ? "Id" : orderBy) + (orderDir ? "" : " desc");
            }

            var url      = $"api/Vendor/GetList/{request.IsActive}/{_customerId}";
            var response = await HttpClientHelper.ApiCall(url, Method.GET);

            if (response.IsSuccessful)
            {
                var result = response.Content;
                list = JsonConvert.DeserializeObject <List <dynamic> >(result).Select(x => new VendorViewModel
                {
                    Id            = x.Id,
                    IsActive      = x.IsActive,
                    CustomerId    = x.CustomerId,
                    VendorCode    = x.VendorCode != null ? x.VendorCode : "",
                    VendorName    = x.VendorName != null ? x.VendorName : "",
                    ContactPerson = x.ContactPerson != null ? x.ContactPerson : "",
                    Telephone     = x.Telephone != null ? x.Telephone : "",
                    MobileNo      = x.MobileNo != null ? x.MobileNo : "",
                    EmailAddress  = x.EmailAddress != null ? x.EmailAddress : "",
                    Website       = x.Website != null ? x.Website : "",
                    Address1      = x.Address1 != null ? x.Address1 : "",
                    Address2      = x.Address2 != null ? x.Address2 : "",
                });

                filteredList = list.Where(x => x.VendorCode.ToLower().Contains(searchBy) ||
                                          x.VendorName.ToLower().Contains(searchBy) ||
                                          x.ContactPerson.ToLower().Contains(searchBy) ||
                                          x.Telephone.ToLower().Contains(searchBy) ||
                                          x.MobileNo.ToLower().Contains(searchBy) ||
                                          x.EmailAddress.ToLower().Contains(searchBy) ||
                                          x.Website.ToLower().Contains(searchBy) ||
                                          x.Address1.ToLower().Contains(searchBy) ||
                                          x.Address2.ToLower().Contains(searchBy)).OrderBy(orderBy, StringComparison.OrdinalIgnoreCase);
            }

            totalResultCount    = list.Count();
            filteredResultCount = filteredList.Count();
            filteredList        = filteredList.Skip(skip).Take(take);

            return(new { filteredList, filteredResultCount, totalResultCount });
        }
Exemplo n.º 3
0
        public async Task <dynamic> SearchFunction(ListFilterViewModels request)
        {
            var list                = new List <CustomerViewModel>().AsEnumerable();
            var filteredList        = new List <CustomerViewModel>().AsEnumerable();
            int filteredResultCount = 0;
            int totalResultCount    = 0;

            var searchBy = request.search.value?.ToLower() ?? "" ?? "";
            var take     = request.length;
            var skip     = request.start;

            var orderBy  = "Id";
            var orderDir = true;

            if (request.order != null)
            {
                orderDir = request.order[0].dir.ToLower().Equals("asc");
                orderBy  = request.columns[request.order[0].column].data;
                orderBy  = (orderBy.Equals("actions", StringComparison.OrdinalIgnoreCase) ? "Id" : orderBy) + (orderDir ? "" : " desc");
            }

            var url      = $"api/Customer/GetList/{request.IsActive}/{_customerId}";
            var response = await HttpClientHelper.ApiCall(url, Method.GET);

            if (response.IsSuccessful)
            {
                var result = response.Content;
                list = JsonConvert.DeserializeObject <List <dynamic> >(result).Select(x => new CustomerViewModel
                {
                    Id           = x.Id,
                    IsActive     = x.IsActive,
                    Domain       = x.Domain ?? "",
                    CompanyName  = x.CompanyName ?? "",
                    EmailAddress = x.EmailAddress ?? "",
                    FirstName    = x.FirstName ?? "",
                    MiddleName   = x.MiddleName != null ? x.MiddleName : "",
                    LastName     = x.LastName ?? "",
                    ContactNo    = x.ContactNo != null ? x.ContactNo : ""
                });

                filteredList = list.Where(x => x.Domain.ToLower().Contains(searchBy) ||
                                          x.CompanyName.ToLower().Contains(searchBy) ||
                                          x.EmailAddress.ToLower().Contains(searchBy) ||
                                          x.ContactNo.ToLower().Contains(searchBy) ||
                                          x.FirstName.ToLower().Contains(searchBy) ||
                                          x.MiddleName.ToLower().Contains(searchBy) ||
                                          x.LastName.ToLower().Contains(searchBy)).OrderBy(orderBy, StringComparison.OrdinalIgnoreCase);
                //(x.FirstName + (!string.IsNullOrEmpty(x.MiddleName) ? " " + x.MiddleName[0] + ". " : " ") + x.LastName)
                //.Contains(searchBy)).OrderBy(orderBy, StringComparison.OrdinalIgnoreCase);
            }

            totalResultCount    = list.Count();
            filteredResultCount = filteredList.Count();
            filteredList        = filteredList.Skip(skip).Take(take);

            return(new { filteredList, filteredResultCount, totalResultCount });
        }
        public async Task <dynamic> SearchFunction(ListFilterViewModels request)
        {
            var list                = new List <ItemViewModel>().AsEnumerable();
            var filteredList        = new List <ItemViewModel>().AsEnumerable();
            int filteredResultCount = 0;
            int totalResultCount    = 0;

            var searchBy = request.search.value?.ToLower() ?? "" ?? "";
            var take     = request.length;
            var skip     = request.start;

            var orderBy  = "Id";
            var orderDir = true;

            if (request.order != null)
            {
                orderDir = request.order[0].dir.ToLower().Equals("asc");
                orderBy  = request.columns[request.order[0].column].data;
                orderBy  = (orderBy.Equals("actions", StringComparison.OrdinalIgnoreCase) ? "Id" : orderBy) + (orderDir ? "" : " desc");
            }

            var url      = $"api/Item/GetList/{request.IsActive}/{_customerId}";
            var response = await HttpClientHelper.ApiCall(url, Method.GET);

            if (response.IsSuccessful)
            {
                var result = response.Content;
                list = JsonConvert.DeserializeObject <List <dynamic> >(result).Select(x => new ItemViewModel
                {
                    Id = x.Id,
                    //CustomerId = x.CustomerId,
                    CustomerId  = x.CustomerId,
                    ProductId   = x.ProductId,
                    BrandId     = x.BrandId,
                    ItemCode    = x.ItemCode,
                    Description = x.Description,
                    ProductCode = x.Product != null ? x.Product.ProductCode : "",
                    ProductDesc = x.Product != null ? x.Product.Description : "",
                    BrandCode   = x.Brand != null ? x.Brand.Code : "",
                    BrandName   = x.Brand != null ? x.Brand.Name : "",
                    IsActive    = x.IsActive
                });

                filteredList = list.Where(x => x.ProductDesc.ToLower().Contains(searchBy) ||
                                          x.BrandName.ToLower().Contains(searchBy) ||
                                          x.ItemCode.ToLower().Contains(searchBy) ||
                                          x.Description.ToLower().Contains(searchBy)).OrderBy(orderBy, StringComparison.OrdinalIgnoreCase);
            }

            totalResultCount    = list.Count();
            filteredResultCount = filteredList.Count();
            filteredList        = filteredList.Skip(skip).Take(take);

            return(new { filteredList, filteredResultCount, totalResultCount });
        }
        public async Task <JsonResult> IndexJson(ListFilterViewModels request)
        {
            var helper = new CustomerClientDataTableSearchHelper();
            var result = await helper.SearchFunction(request);

            var resultList = (IEnumerable <CustomerClientViewModel>)result.filteredList;

            var data = resultList.Select(x => new
            {
                Actions = "<div class='btn-group' style='display:flex;'>" +
                          "<a class='btn btn-primary' href='#'><i class='fa fa-gear fa-fw'></i> Action</a>" +
                          "<a class='btn btn-primary dropdown-toggle' data-toggle='dropdown' href='#'>" +
                          "<span class='fa fa-caret-down' title='Toggle dropdown menu'></span>" +
                          "</a>" +
                          "<ul class='dropdown-menu' role='menu'>" +
                          (x.IsActive ? "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Edit") + "' onclick='btnClicked($(this))'><a>Edit</a></li>" : "") +
                          "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Details") + "' onclick='btnClicked($(this))'><a>Details</a></li>" +
                          (x.IsActive ? "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Delete") + "' onclick='btnClicked($(this))'><a>Delete</a></li>" :
                           "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Enable") + "' onclick='btnClicked($(this))'><a>Enable</a></li>") +
                          "</ul>" +
                          "</div>",
                CustomerCode  = x.CustomerCode,
                Description   = x.Name,
                ContactPerson = x.ContactPerson,
                Telephone     = x.Telephone,
                MobileNo      = x.MobileNo,
                EmailAddress  = x.EmailAddress,
                Website       = x.Website,
                Address1      = x.Address1,
                Address2      = x.Address2,
                IsActve       = x.IsActive
            });

            return(Json(new
            {
                draw = request.draw,
                recordsTotal = result.totalResultCount,
                recordsFiltered = result.filteredResultCount,
                data = data
            }));
        }
Exemplo n.º 6
0
        public async Task <JsonResult> IndexJson(ListFilterViewModels request)
        {
            var helper = new CustomerDataTableSearchHelper();
            var result = await helper.SearchFunction(request);

            var resultList = (IEnumerable <CustomerViewModel>)result.filteredList;

            var data = resultList.Select(x => new
            {
                Actions = "<div class='btn-group' style='display:flex;'>" +
                          "<a class='btn btn-primary' href='#'><i class='fa fa-gear fa-fw'></i> Action</a>" +
                          "<a class='btn btn-primary dropdown-toggle' data-toggle='dropdown' href='#'>" +
                          "<span class='fa fa-caret-down' title='Toggle dropdown menu'></span>" +
                          "</a>" +
                          "<ul class='dropdown-menu' role='menu'>" +
                          (x.IsActive ? "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Edit") + "' onclick='btnClicked($(this))'><a>Edit</a></li>" : "") +
                          "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Details") + "' onclick='btnClicked($(this))'><a>Details</a></li>" +
                          (x.IsActive ? "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Delete") + "' onclick='btnClicked($(this))'><a>Disable</a></li>" :
                           "<li class='crud' data-id='" + x.Id + "' data-request-url='" + Url.Action("Enable") + "' onclick='btnClicked($(this))'><a>Enable</a></li>") +
                          "</ul>" +
                          "</div>",
                FullName     = x.FirstName + (!string.IsNullOrEmpty(x.MiddleName) ? " " + x.MiddleName[0] + ". " : " ") + x.LastName,
                EmailAddress = x.EmailAddress,
                Domain       = x.Domain,
                CompanyName  = x.CompanyName,
                ContactNo    = x.ContactNo,
                IsActive     = x.IsActive
            });

            return(Json(new
            {
                draw = request.draw,
                recordsTotal = result.totalResultCount,
                recordsFiltered = result.filteredResultCount,
                data = data
            }));
        }