public async Task <dynamic> SearchFunction(ExpectedReceiptFilterViewModels request, bool IsPlanned) { var list = new List <ExpectedReceiptViewModel.ExpectedReceipt>().AsEnumerable(); var filteredList = new List <ExpectedReceiptViewModel.ExpectedReceipt>().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"); } DateTime dt; DateTime?sDateFrom = null; if (DateTime.TryParse(request.from, out dt)) { sDateFrom = Convert.ToDateTime(request.from); } DateTime?sDateTo = null; if (DateTime.TryParse(request.to, out dt)) { sDateTo = Convert.ToDateTime(request.to).AddDays(1); } var url = ""; if (request.StatusCode.Equals("Received")) { url = $"api/GoodsIn/ExpectedReceipt/GetReceived/{request.IsActive}/{_customerId}/"; } else if (request.StatusCode.Equals("Completed")) { url = $"api/GoodsIn/ExpectedReceipt/GetCompleted/{request.IsActive}/{_customerId}/"; } else if (request.StatusCode.Equals("For Receiving") && IsPlanned) { url = $"api/GoodsIn/ExpectedReceipt/GetForReceiving/{request.IsActive}/{_customerId}/"; } else if (request.StatusCode.Equals("ALL")) { url = $"api/GoodsIn/ExpectedReceipt/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 ExpectedReceipt { Id = x.Id, IsActive = x.IsActive, WarehouseDescription = x.Warehouse != null ? x.Warehouse.Description : "", ExpectedReceiptDate = x.ExpectedReceiptDate, GoodsReceivedNumber = x.GoodsReceivedNumber ?? "", ReferenceNumber = x.ReferenceNumber != null ? x.ReferenceNumber : "", AutoReferenceNumber = x.AutoReferenceNumber != null ? x.AutoReferenceNumber : "", //Received = x.Received, Comments = x.Comments ?? "", Address = x.Warehouse != null ? x.Warehouse.Address1 : "", WarehouseCode = x.Warehouse != null ? x.Warehouse.Description : "", ReceivedBy = x.ReceivedBy != null ? x.ReceivedBy : "", ReceivedDate = x.ReceivedDate, Supplier = x.Supplier != null ? x.Supplier : "", HaulierName = x.Haulier != null ? x.Haulier.Name : "", HaulierCode = x.Haulier != null ? x.Haulier.HaulierCode : "", StatusCode = x.Status != null ? x.Status.Name : "", Planned = x.Planned }).Where(x => x.Planned == IsPlanned).ToList(); filteredList = list.Where(x => x.ExpectedReceiptDate.ToString("MMM. dd, yyyy").ToLower().Contains(searchBy) || x.AutoReferenceNumber.ToLower().Contains(searchBy) || x.GoodsReceivedNumber.ToLower().Contains(searchBy) || x.ReferenceNumber.ToLower().Contains(searchBy) || (x.ReceivedDate?.ToString("MMM. dd, yyyy").ToLower().Contains(searchBy) ?? false) || x.ReceivedBy.ToLower().Contains(searchBy) || x.StatusCode.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 <dynamic> SearchFunction(DeliveryRequestFilterViewModels request) { var list = new List <DeliveryRequestViewModel>().AsEnumerable(); var filteredList = new List <DeliveryRequestViewModel>().AsEnumerable(); int filteredResultCount = 0; int totalResultCount = 0; var searchBy = request.search?.value ?? ""; searchBy = searchBy?.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/GoodsOut/DeliveryRequest/GetList/{request.IsActive}/{_customerId}/{request.StatusId}"; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; list = JsonConvert.DeserializeObject <List <dynamic> >(result).Select(x => new DeliveryRequestViewModel { Id = x.Id, CustomerId = x.CustomerId, IsActive = x.IsActive, CustomerClientName = x.CustomerClient != null ? x.CustomerClient : "", DeliveryRequestCode = x.DeliveryRequestCode != null ? x.DeliveryRequestCode : "", HaulierName = x.Haulier != null ? x.Haulier : "", RequestedDate = x.RequestedDate != null ? x.RequestedDate : DateTime.MinValue, RequestType = x.RequestType != null ? x.RequestType : "", SalesOrderRef = x.SalesOrderRef != null ? x.SalesOrderRef : "", WarehouseDescription = x.Warehouse != null ? x.Warehouse : "", StatusId = x.StatusId, StatusName = x.Status != null ? x.Status : "" }).ToList(); filteredList = list.Where(x => x.CustomerClientName.ToLower().Contains(searchBy) || x.DeliveryRequestCode.ToLower().Contains(searchBy) || x.HaulierName.ToLower().Contains(searchBy) || x.RequestedDate.ToString("MMM. dd, yyyy").ToLower().Contains(searchBy) || x.RequestType.ToLower().Contains(searchBy) || x.SalesOrderRef.ToLower().Contains(searchBy) || x.WarehouseDescription.ToLower().Contains(searchBy) || x.StatusName.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 <dynamic> SearchFunction(ListFilterLineViewModels request) { var list = new List <ExpectedReceiptViewModel.ExpectedReceiptLine>().AsEnumerable(); var filteredList = new List <ExpectedReceiptViewModel.ExpectedReceiptLine>().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/GoodsIn/ExpectedReceipt/GetByExpectedReceipt/{request.HeaderId}/{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 ExpectedReceiptViewModel.ExpectedReceiptLine { Id = x.Id, IsActive = x.IsActive, ExpectedReceiptId = x.ExpectedReceiptId, Quantity = x.Quantity, BrandId = x.BrandId, ProductId = x.ProductId, BrandName = x.Brand != null ? x.Brand.Name : "", Batch = x.Batch, ItemCode = x.ItemCode, ItemDescription = x.ItemDescription != null ? x.ItemDescription : "", ExpiryDate = x.ExpiryDate, UomDescription = x.Uom != null ? x.Uom.Description : "", ProductCode = x.Product != null ? x.Product.Description : "", StatusCode = x.ExpectedReceipt != null ? x.ExpectedReceipt.Status.Name : "", GoodsReceivedNumber = x.ExpectedReceipt != null ? x.ExpectedReceipt.GoodsReceivedNumber : "" }).ToList(); filteredList = list.Where(x => (x.ExpiryDate?.ToString("MMM. dd, yyyy").ToLower().Contains(searchBy) ?? false) || x.ItemCode.ToLower().Contains(searchBy) || x.BrandName.ToLower().Contains(searchBy) || x.ItemDescription.ToLower().Contains(searchBy) || x.Quantity.ToString().ToLower().Contains(searchBy) || x.UomDescription.ToLower().Contains(searchBy)); } 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 <CustomerClientViewModel>().AsEnumerable(); var filteredList = new List <CustomerClientViewModel>().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/CustomerClient/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 CustomerClientViewModel { Id = x.Id, IsActive = x.IsActive, CustomerId = x.CustomerId, CustomerCode = x.CustomerCode ?? "", Name = x.Name != null ? x.Name : "", ContactPerson = x.ContactPerson != null ? x.ContactPerson : "", Telephone = x.Telephone != null ? x.Telephone : "", EmailAddress = x.EmailAddress != null ? x.EmailAddress : "", Website = x.Website != null ? x.Website : "", Address1 = x.Address1 != null ? x.Address1 : "", Address2 = x.Address2 != null ? x.Address2 : "", MobileNo = x.MobileNo != null ? x.MobileNo : "" }); filteredList = list.Where(x => x.CustomerCode.ToLower().Contains(searchBy) || x.Name.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 }); }