public List <ProductClientModel> GetProductsClientByClientId(string clientId)
        {
            var qa = (from pc in _context.ProductsClients
                      join p in _context.Products
                      on pc.ProductId equals p.Id
                      where pc.ClientId == clientId
                      select new
            {
                Id = pc.Id,
                Cantidad = pc.Ammount,
                Nombre = p.Name,
                Precio = p.Value
            });;

            List <ProductClientModel> res = new List <ProductClientModel>();

            foreach (var el in qa)
            {
                ProductClientModel productClient = new ProductClientModel();
                productClient.Cantidad = el.Cantidad.ToString();
                productClient.Id       = el.Id;
                productClient.Nombre   = el.Nombre;
                productClient.Precio   = el.Precio;
                res.Add(productClient);
            }

            return(res);
        }
Esempio n. 2
0
        public ActionResult List(ProductClientSearchCondition condition)
        {
            var splits = Regex.Split(condition.Range, " - ");

            condition.MinPrice   = GetPrice(splits[0]);
            condition.MaxPrice   = GetPrice(splits[1]);
            condition.PageSize   = Values.ProductClientPageSize;
            condition.PageNumber = 0;
            var products          = _productService.SearchProducts(condition);
            var bestSellerProduct = _productService.GetHostestProducts(Values.BestSellerNumber);
            var model             = new ProductClientModel()
            {
                Products           = products,
                BestSellerProducts = bestSellerProduct,
                SearchCondition    = condition
            };

            return(View(model));
        }
Esempio n. 3
0
        public ActionResult List(int categoryId)
        {
            var condition = new ProductClientSearchCondition()
            {
                ProductCategoryId = categoryId,
                PageSize          = Values.ProductClientPageSize,
                PageNumber        = 0,
            };
            var products          = _productService.SearchProducts(condition);
            var bestSellerProduct = _productService.GetHostestProducts(Values.BestSellerNumber);
            var model             = new ProductClientModel()
            {
                Products           = products,
                SearchCondition    = condition,
                BestSellerProducts = bestSellerProduct
            };

            return(View(model));
        }