/// <summary> /// Get records for datatable /// </summary> /// <param name="param"></param> /// <returns></returns> //[HttpPost] public async Task <ActionResult> GetList(JqueryDatatableParam param) { ProductDatatable productDatatable = new ProductDatatable(); try { ProductListFilter model = new ProductListFilter { Start = param.Start, Length = param.Length, Search = param.Search.Value, SortColumn = Convert.ToString(param.Columns[param.Order[0].Column].Data), SortOrder = Convert.ToString(param.Order[0].Dir) }; ResJsonOutput result = await PostDataAsync("/API/Products/GetProductList", model); if (result.Status.IsSuccess) { productDatatable = Utility.ConvertJsonToObject <ProductDatatable>(result.Data); } } catch (Exception ex) { throw; } return(Json(new { draw = param.Draw, data = productDatatable.Products, recordsFiltered = productDatatable.TotalRecords, recordsTotal = productDatatable.TotalDisplayRecord })); }
public ActionResult <ResJsonOutput> GetProductList([FromBody] ProductListFilter param) { ResJsonOutput result = new ResJsonOutput(); try { ProductDatatable productDatatable = new ProductDatatable(); List <Product> list = product.GetAll().ToList(); if (list != null && list.Count() > 0) { productDatatable.TotalDisplayRecord = productDatatable.TotalRecords = list.Count(); if (!string.IsNullOrEmpty(param.Search)) { list = list.Where(x => x.ProductName.ToLower().Contains(param.Search.ToLower()) || x.ProductPrice.ToString().ToLower().Contains(param.Search.ToLower()) ).ToList(); productDatatable.TotalRecords = productDatatable.TotalDisplayRecord = list.Count(); } list = SortedDataByColumn(list, param.SortColumn, param.SortOrder); list = list.Skip(param.Start).Take(param.Length).ToList(); } productDatatable.Products = list; result.Data = productDatatable; result.Status.IsSuccess = true; } catch (Exception ex) { result = GetException(ex); } return(result); }
public async Task <dynamic> AutoComplete([FromUri] ProductListFilter filter) { filter = filter ?? new ProductListFilter(); var result = await _sqlData.Product.AutoComplete(filter); return(new { Result = JsonConvert.DeserializeObject(result) }); }
public void ProductListFilter_DoesNotHaveRequiredFields() { // Arrange _filter = new ProductListFilter(); // Act var keyValuePairs = StripeClient.GetModelKeyValuePairs(_filter).ToList(); // Assert keyValuePairs.Should().HaveCount(0); }
public async Task <StripeResponse <Pagination <Product> > > GetProducts(ProductListFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <ProductListFilter, Pagination <Product> > { UrlPath = Paths.Products, Model = filter }; return(await _client.Get(request, cancellationToken)); }
public async Task GetProductsTest() { // Arrange var filter = new ProductListFilter(); _stripe.Get( Arg.Is <StripeRequest <ProductListFilter, Pagination <Product> > >( a => a.UrlPath == "products" && a.Model == filter), _cancellationToken) .Returns(Task.FromResult(new StripeResponse <Pagination <Product> >())); // Act var response = await _client.GetProducts(filter, _cancellationToken); // Assert response.Should().NotBeNull(); }
//**********POLICIES********************* //policies /// <summary> /// /// </summary> /// <param name="info">info ["data"]</param> /// <returns></returns> private IBooleanExpression createLeaf(JObject info) { string leafType = (string)info["type"]; //create products filter string products = (string)info["products"]; ItemFilter filter; if (products == "-1") { filter = new AllProductsFilter(); } else { string[] productsArr = products.Split(',').ToArray(); List <int> productsList = new List <int>(); foreach (string curr in productsArr) { productsList.Add(Convert.ToInt32(curr)); } filter = new ProductListFilter(productsList); } switch (leafType) { case "min": return(new MinAmount((int)info["data"], filter)); case "max": return(new MaxAmount((int)info["data"], filter)); case "country": return(new UserCountry((string)info["data"], filter)); case "age": return(new UserAge((int)info["data"], filter)); default: Logger.Log("error", logLevel.ERROR, "can't create leaf"); throw new Exception("can't create leaf"); } }
public void Init() { _filter = GenFu.GenFu.New <ProductListFilter>(); }
/// <summary> /// Gets a list of up to 250 of the shop's products. /// </summary> public virtual async Task <ListResult <Product> > ListAsync(ProductListFilter filter = null, bool includePresentmentPrices = false, CancellationToken cancellationToken = default) { return(await ListAsync(filter?.AsListFilter(), includePresentmentPrices, cancellationToken)); }
/// <summary> /// Gets a list of up to 250 of the shop's products. /// </summary> public virtual async Task <ListResult <Product> > ListAsync(ProductListFilter filter = null) { return(await ListAsync(filter?.AsListFilter())); }
public async Task <IEnumerable <ProductDto> > GetAll(ProductList list) { var result = new List <ProductDto>(); try { var _filter = new ProductListFilter(); if (!string.IsNullOrEmpty(list.Filter)) { _filter = JsonConvert.DeserializeObject <ProductListFilter>(list.Filter); var query = ( from p in _context.Product where _filter.ProductName.Equals(p.ProductName) select new ProductDto { Id = p.Id, ProductName = p.ProductName, Quantity = p.Quantity, Price = p.Price, UserId = p.UserId, UrlImage = p.UrlImage, Likes = _context.LikeProduct.Count(x => x.ProductId == p.Id), ILikedIt = _context.LikeProduct.Any(x => x.UserId == _filter.UserId && x.ProductId == p.Id) } ).Take(list.Take); result = await query.ToListAsync(); } else if (list.Take > 0) { var query = ( from p in _context.Product select new ProductDto { Id = p.Id, ProductName = p.ProductName, Quantity = p.Quantity, Price = p.Price, UserId = p.UserId, UrlImage = p.UrlImage, Likes = _context.LikeProduct.Count(x => x.ProductId == p.Id), ILikedIt = false } ).Take(list.Take); result = await query.ToListAsync(); } else { var query = ( from p in _context.Product select new ProductDto { Id = p.Id, ProductName = p.ProductName, Quantity = p.Quantity, Price = p.Price, UserId = p.UserId, UrlImage = p.UrlImage, Likes = _context.LikeProduct.Count(x => x.ProductId == p.Id), ILikedIt = false } ); result = await query.ToListAsync(); } } catch (Exception e) { } return(result); }
/// <summary> /// Gets a list of up to 250 of the shop's products. /// </summary> public virtual async Task <ListResult <Entities.Product> > ListAsync(ProductListFilter filter = null, CancellationToken cancellationToken = default) { return(await ListAsync(filter?.AsListFilter(), cancellationToken)); }