GetProducts() 개인적인 메소드

private GetProducts ( int cateogryID ) : List
cateogryID int
리턴 List
예제 #1
0
        /// <summary>
        /// Gets the products.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <param name="xml">The XML.</param>
        /// <returns></returns>
        public string GetProducts(Guid siteId, string username, string password, string xml)
        {
            var user = _authorization.Authorize(siteId, username, password);

            if (user == null || !Access.Check(user, "API").Read || (user.AccessLevelID != (int)AccessLevel.Administrator && user.AccessLevelID != (int)AccessLevel.SystemAdministrator))
            {
                return(StatusHelper.FormatMessage(StatusCodes.AccessDenied, MethodBase.GetCurrentMethod().Name, _result).ToString(SaveOptions.DisableFormatting));
            }

            XDocument inputXml;

            try
            {
                inputXml = XDocument.Parse(xml);
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("LeadForce.API.GetProducts error, SiteId: {0}, UserName: {1}, Xml: {2}", siteId, username, xml), ex);
                return(StatusHelper.FormatMessage(StatusCodes.InvalidParameters, MethodBase.GetCurrentMethod().Name, _result).ToString(SaveOptions.DisableFormatting));
            }

            try
            {
                var products = Products.GetProducts(siteId, inputXml);
                _result = StatusHelper.FormatMessage(StatusCodes.Ok, MethodBase.GetCurrentMethod().Name, _result);
                _result.Document.Element("LeadForceResponse").Add(new XElement("Result", products.Document.FirstNode));
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("LeadForce.API.GetProducts error, SiteId: {0}, UserName: {1}, Xml: {2}", siteId, username, xml), ex);
                return(StatusHelper.FormatMessage(StatusCodes.InternalError, MethodBase.GetCurrentMethod().Name, _result).ToString(SaveOptions.DisableFormatting));
            }

            return(_result.ToString(SaveOptions.DisableFormatting));
        }
예제 #2
0
        public IActionResult Get([DataTablesRequest] DataTablesRequest dataRequest)
        {
            IEnumerable <Product> products = Products.GetProducts();
            int recordsTotal   = products.Count();
            int recordsFilterd = recordsTotal;

            if (!string.IsNullOrEmpty(dataRequest.Search?.Value))
            {
                products       = products.Where(e => e.Name.Contains(dataRequest.Search.Value));
                recordsFilterd = products.Count();
            }
            products = products.Skip(dataRequest.Start).Take(dataRequest.Length);

            return(Json(products
                        .Select(e => new
            {
                Id = e.Id,
                Name = e.Name,
                Created = e.Created,
                Salary = e.Salary,
                Position = e.Position,
                Office = e.Office
            })
                        .ToDataTablesResponse(dataRequest, recordsTotal, recordsFilterd)));
            //return Json(new {
            //    draw = dataRequest.Draw,
            //    recordsTotal = products.Count(),
            //    recordsFiltered = products.Count(),
            //    data = products.Select(e => new {  Id = e.Id, Name = e.Name, Created = e.Created, Price = 10 })
            //});
        }
예제 #3
0
        // GET: Person
        public ActionResult List()
        {
            var products = new Products();
            var models   = products.GetProducts();

            return(View(models));
        }
예제 #4
0
    public void BindProducts()
    {
        int pageNumber = WebUtility.LoadInt32FromQueryString("Page");

        if (pageNumber == -1)
        {
            pageNumber = 0;
        }
        int categoryID = WebUtility.LoadInt32FromQueryString("CategoryID");

        if (categoryID == -1)
        {
            categoryID = 1;
        }
        SortOrder sortOrder = SortOrder.DontSort;

        Enum.TryParse <SortOrder>(WebUtility.LoadStringFromQueryString("Sort", 200, true), out sortOrder);

        ProductsGrid.PageNumber = pageNumber;
        ProductsGrid.PageSize   = 4;
        ProductsGrid.Columns    = 3;
        Products products = new Products();

        ProductsGrid.DataSource   = products.GetProducts(categoryID, pageNumber, ProductsGrid.PageSize, sortOrder);
        ProductsGrid.TotalRecords = products.ProductCount;
        ProductsGrid.DataBind();
    }
예제 #5
0
        // GET: Products
        public ActionResult Index()
        {
            var products         = new Products();
            var productsModels   = new ProductModels();
            var productModelList = productsModels.GetProductModels(products.GetProducts());

            return(View(productModelList));
        }
예제 #6
0
        string RenderHTML()
        {
            if (_Cache.ContainsKey(_IndustryID))
            {
                return(_Cache[_IndustryID]);
            }
            List <ProductIndustry> inds = ProductIndustries.GetChildIndustries(0);
            StringBuilder          sb   = new StringBuilder();

            if (_IndustryID == 0)
            {
                return("<div class=\"" + _CssClass + "\"><span>暂无相关行业信息!</span></div>");
            }
            else
            {
                ProductIndustry pi = ProductIndustries.GetProductIndustry(_IndustryID);
                if (pi.ParentID == 0)
                {
                    return("<div class=\"" + _CssClass + "\"><span>此行业为顶级行业分类!</span></div>");
                }
                List <ProductIndustry> pis = ProductIndustries.GetChildIndustries(pi.ParentID);

                if (pis == null || pis.Count == 0 || (pis.Count == 1 && pis[0].IndustryID == _IndustryID))
                {
                    return("<div class=\"" + _CssClass + "\"><span>暂无相关行业信息!</span></div>");
                }
                sb.Append("<div class=\"" + _CssClass + "\">");
                ProductQuery            query;
                int                     count = 0;
                PagingDataSet <Product> __ps  = null;
                foreach (ProductIndustry p in pis)
                {
                    if (p.IndustryID != _IndustryID)
                    {
                        count            = 0;
                        query            = new ProductQuery();
                        query.IndustryID = p.IndustryID;
                        __ps             = Products.GetProducts(query);
                        if (__ps != null && __ps.Records != null)
                        {
                            count = Products.GetProducts(query).Records.Count;
                        }
                        sb.AppendFormat(_href, GlobalSettings.Encrypt(p.IndustryID.ToString()), p.IndustryName + "(" + count + ")");
                    }
                }
                sb.Append("</div>");
                if (!_Cache.ContainsKey(_IndustryID))
                {
                    lock (_lock)
                        if (!_Cache.ContainsKey(_IndustryID))
                        {
                            _Cache.Add(_IndustryID, sb.ToString());
                        }
                }
                return(sb.ToString());
            }
        }
예제 #7
0
        private void RemoveProductEvent(object sender, EventArgs e)
        {
            var element = Products.GetProducts()
                          .FirstOrDefault(item => string.Equals(item.Name, this.productList.SelectedItem.ToString(),
                                                                StringComparison.CurrentCultureIgnoreCase));

            Products.ProductsList.Remove(element);
            RefreshProductList();
        }
예제 #8
0
    private void BindTopProducts()
    {
        Products p = new Products();

        p.GetProducts((int)Enumerations.ProductCat.Top);

        ListView_Products.DataSource = p;
        ListView_Products.DataBind();
    }
예제 #9
0
        // GET: Products/Details/{id}
        public ActionResult Details(int id)
        {
            var products         = new Products();
            var productsModels   = new ProductModels();
            var productModelList = productsModels.GetProductModels(products.GetProducts());
            var product          = productModelList.Find(x => x.id == id);

            return(View(product));
        }
예제 #10
0
        public ShopPage()
        {
            Products products = new Products();

            InitializeComponent();


            list = products.GetProducts();
            listview1.ItemsSource = list;
        }
        public ActionResult ProductTable(string search)
        {
            var product = productsService.GetProducts();

            if (string.IsNullOrEmpty(search) == false)
            {
                product = product.Where(p => p.Name != null && p.Name.ToLower().Contains(search.ToLower())).ToList();
            }
            return(PartialView(product));
        }
예제 #12
0
        void InitProducts()
        {
            Server2Client sc  = new Server2Client();
            Products      prd = new Products();

            sc = prd.GetProducts();
            luePNM.Properties.DataSource    = sc.dataTable;
            luePNM.Properties.DisplayMember = "ProductName";
            luePNM.Properties.ValueMember   = "ID";
        }
예제 #13
0
 public void PopulateProductData()
 {
     products = Products.GetProducts();
     productCombo.Items.Clear();
     foreach (var item in products)
     {
         productCombo.Items.Add(item.ProductName);
     }
     productCombo.SelectedIndex = 0;
 }
        string RenderHTML()
        {
            if (_Cache.ContainsKey(_CategoryID))
            {
                return(_Cache[_CategoryID]);
            }
            List <ProductCategory> pcs = ProductCategories.GetCategories();
            StringBuilder          sb  = new StringBuilder();

            if (_CategoryID == 0)
            {
                return("<div class=\"" + _CssClass + "\"><span>暂无子分类信息!</span></div>");
            }
            else
            {
                string                 _catId  = string.Empty;
                ProductCategory        curCat  = null;
                List <ProductCategory> subCats = ProductCategories.GetChidCategories(_CategoryID);
                if (subCats == null || subCats.Count == 0)
                {
                    return("<div class=\"" + _CssClass + "\"><span>暂无子分类信息!</span></div>");
                }
                sb.Append("<div class=\"" + _CssClass + "\">");
                ProductQuery            query;
                int                     count = 0;
                PagingDataSet <Product> __ps  = null;
                for (int i = 0; i < subCats.Count; i++)
                {
                    curCat           = subCats[i];
                    count            = 0;
                    query            = new ProductQuery();
                    query.CategoryID = curCat.CategoryID;

                    __ps = Products.GetProducts(query);
                    if (__ps != null && __ps.Records != null)
                    {
                        count = Products.GetProducts(query).Records.Count;
                    }

                    sb.AppendFormat(_href, GlobalSettings.Encrypt(curCat.CategoryID.ToString()), curCat.CategoryName + "(" + count + ")");
                }
                sb.Append("</div>");
                if (!_Cache.ContainsKey(_CategoryID))
                {
                    lock (_lock)
                    {
                        if (!_Cache.ContainsKey(_CategoryID))
                        {
                            _Cache.Add(_CategoryID, sb.ToString());
                        }
                    }
                }
            }
            return(sb.ToString());
        }
예제 #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Products p = new Products();
            p.GetProducts((int)Enumerations.ProductCat.Kids);

            ListView_Products.DataSource = p;
            ListView_Products.DataBind();
        }
    }
예제 #16
0
        string RenderHTML()
        {
            if (_Cache.ContainsKey(_IndustryID))
            {
                return(_Cache[_IndustryID]);
            }
            List <ProductIndustry> inds = ProductIndustries.GetChildIndustries(0);

            StringBuilder sb = new StringBuilder();

            if (_IndustryID == 0)
            {
                return("<div class=\"" + _CssClass + "\"><span>暂无子行业信息!</span></div>");
            }
            else
            {
                string                 _indId = string.Empty;
                ProductIndustry        pi     = null;
                List <ProductIndustry> pis    = ProductIndustries.GetChildIndustries(_IndustryID);
                if (pis == null || pis.Count == 0)
                {
                    return("<div class=\"" + _CssClass + "\"><span>暂无子行业信息!</span></div>");
                }
                sb.Append("<div class=\"" + _CssClass + "\">");
                ProductQuery            query;
                int                     count = 0;
                PagingDataSet <Product> __ps  = null;
                for (int i = 0; i < pis.Count; i++)
                {
                    pi               = pis[i];
                    count            = 0;
                    query            = new ProductQuery();
                    query.IndustryID = pi.IndustryID;
                    __ps             = Products.GetProducts(query);
                    if (__ps != null && __ps.Records != null)
                    {
                        count = Products.GetProducts(query).Records.Count;
                    }
                    sb.AppendFormat(_href, GlobalSettings.Encrypt(pi.IndustryID.ToString()), pi.IndustryName + "(" + count + ")");
                }
                sb.Append("</div>");
                if (!_Cache.ContainsKey(_IndustryID))
                {
                    lock (_lock)
                        if (!_Cache.ContainsKey(_IndustryID))
                        {
                            _Cache.Add(_IndustryID, sb.ToString());
                        }
                }
            }
            return(sb.ToString());
        }
예제 #17
0
        string RenderHTML()
        {
            if (_Cache.ContainsKey(_BrandID))
            {
                return(_Cache[_BrandID]);
            }
            if (_BrandID == 0)
            {
                return("<div class=\"" + _CssClass + "\"><span>暂无相关品牌信息!</span></div>");
            }
            else
            {
                List <ProductBrand> brands = ProductBrands.GetProductBrands();
                StringBuilder       sb     = new StringBuilder();
                ProductBrand        pb     = ProductBrands.GetProductBrand(_BrandID);

                List <ProductBrand> bs = GetSubBrand(pb.BrandGroup, brands);
                if (bs == null || bs.Count == 0 || (bs.Count == 1 && bs[0].BrandID == _BrandID))
                {
                    return("<div class=\"" + _CssClass + "\"><span>暂无相关品牌信息!</span></div>");
                }
                sb.Append("<div class=\"" + _CssClass + "\">");
                ProductQuery            query;
                int                     count = 0;
                PagingDataSet <Product> __ps  = null;
                foreach (ProductBrand b in bs)
                {
                    if (b.BrandID != _BrandID)
                    {
                        count         = 0;
                        query         = new ProductQuery();
                        query.BrandID = b.BrandID;
                        __ps          = Products.GetProducts(query);
                        if (__ps != null && __ps.Records != null)
                        {
                            count = Products.GetProducts(query).Records.Count;
                        }
                        sb.AppendFormat(_href, GlobalSettings.Encrypt(b.BrandID.ToString()), b.BrandName + "(" + count + ")");
                    }
                }
                sb.Append("</div>");
                if (!_Cache.ContainsKey(_BrandID))
                {
                    lock (_lock)
                        if (!_Cache.ContainsKey(_BrandID))
                        {
                            _Cache.Add(_BrandID, sb.ToString());
                        }
                }
                return(sb.ToString());
            }
        }
예제 #18
0
    private void BindListView()
    {
        Products p = new Products();

        p.GetProducts(null);

        ListView_Products.DataSource = p;
        ListView_Products.DataBind();


        repOrderedList.DataSource = p;
        repOrderedList.DataBind();
    }
예제 #19
0
    private void BindListView()
    {
        Products p = new Products();

        p.GetProducts((int)Enumerations.ProductCat.Group9);

        ListView_Products.DataSource = p;
        ListView_Products.DataBind();


        repOrderedList.DataSource = p;
        repOrderedList.DataBind();
    }
예제 #20
0
        private void ProductListEvent(object sender, EventArgs e)
        {
            if (this.productList.SelectedItem == null)
            {
                return;
            }

            var element = Products.GetProducts()
                          .FirstOrDefault(item => string.Equals(item.Name, this.productList.SelectedItem.ToString(),
                                                                StringComparison.CurrentCultureIgnoreCase));

            this.productNameText.Text     = element.Name;
            this.productCategoryText.Text = element.Category;
            this.productPriceText.Text    = element.Price.ToString(CultureInfo.InvariantCulture);
        }
예제 #21
0
        public ActionResult ProductEdit(int id)
        {
            Products product = products.GetProducts(id);

            if (Session["Admin"] == null)
            {
                this.Response.Redirect("/Admin/Home/Login");
            }
            var product_categories = db.GetAllProductCategories();
            var brands             = db.GetAllBrands();

            ViewBag.Product_categories = product_categories;
            ViewBag.Brands             = brands;
            return(View(product));
        }
예제 #22
0
        public MainWindow()
        {
            InitializeComponent();
            InitializeRuleChecker();

            var headerText = Properties.Settings.Default.OrderHeader;

            if (!string.IsNullOrEmpty(headerText))
            {
                OrderHeaderText.Text = headerText;
            }

            CustomerComboBox.ItemsSource = People.GetPeople().OrderBy(p => p.LastName);
            ProductComboBox.ItemsSource  = Products.GetProducts();

            ResetOrder();
        }
예제 #23
0
        public MainWindow()
        {
            InitializeComponent();
            InitializeRuleChecker();

            var headerText = ConfigurationManager.AppSettings["OrderHeader"];

            if (!string.IsNullOrEmpty(headerText))
            {
                OrderHeaderText.Text = headerText;
            }

            CustomerComboBox.ItemsSource = People.GetPeople().OrderBy(p => p.FamilyName);
            ProductComboBox.ItemsSource  = Products.GetProducts();

            ResetOrder();
        }
예제 #24
0
    private void PopulateLookups()
    {
        //categories checkbox
        var _cat = new Categories();

        _cat.GetCategories();

        foreach (Category t in _cat)
        {
            ListItem li = new ListItem(t.CatName, t.Id.ToString());
            this.cbCat.Items.Add(li);
        }


        //Fixed Sizes checkbox
        var _sizes = new Sizes();

        _sizes.GetSizes();

        foreach (Size s in _sizes)
        {
            ListItem li = new ListItem(s.SizeCode, s.SizeId.ToString());
            this.cbSizes.Items.Add(li);
        }


        var _pro = new Products();

        _pro.GetProducts(null);

        this.ddlProducts.Items.Add(new ListItem("New Product", "-1"));
        foreach (Product p in _pro)
        {
            ListItem li = new ListItem(p.ProductName, p.ProductId.ToString());
            this.ddlProducts.Items.Add(li);
        }
    }
    void BindData()
    {
        ProductQuery query = this.Query;

        lnkGrid.PostBackUrl = Request.RawUrl;
        lnkList.PostBackUrl = Request.RawUrl;
        lnkGrid.Attributes.Add("rel", "grid");
        lnkList.Attributes.Add("rel", "list");

        #region -Adapt Show-
        string s = Request.QueryString["s"];
        if (!string.IsNullOrEmpty(s))
        {
            switch (s)
            {
            case "grid":
                lnkGrid.CssClass   = "showByGrid showBy showByGridActive";
                lnkList.CssClass   = "showByList showBy";
                cpProduct.PageSize = 10;
                break;

            case "list":
                lnkList.CssClass   = "showByList showBy showByListActive";
                lnkGrid.CssClass   = "showByGrid showBy";
                cpProduct.PageSize = 50;
                break;
            }
        }
        else
        {
            cpProduct.PageSize = 10;
            s = "grid";
            lnkGrid.CssClass = "showByGrid showBy showByGridActive";
            lnkList.CssClass = "showByList showBy";
        }
        #endregion

        #region -BindData-
        string         sortBy    = Request.QueryString["sortby"];
        ProductOrderBy orderBy   = ProductOrderBy.DisplayOrder;
        SortOrder      sortOrder = SortOrder.Descending;
        if (!string.IsNullOrEmpty(sortBy))
        {
            try
            {
                ddlSortBy.Items.FindByValue(sortBy).Selected = true;
            }
            catch { ddlSortBy.SelectedIndex = 0; }
            GetData(out orderBy, out sortOrder, sortBy);
        }
        query.ProductOrderBy = orderBy;
        query.SortOrder      = sortOrder;
        query.PageSize       = int.MaxValue;
        query.HasPublished   = true;
        List <Product> prods = null;
        if (!IsSearch)
        {
            prods = Products.GetProducts(query).Records;
        }
        else
        {
            if (string.IsNullOrEmpty(query.ProductNameFilter))
            {
                prods = Products.GetProducts(query).Records;
            }
            else
            {
                SearchResultDataSet <Product> _pros = ProductSearchManager.Search(query);
                prods                 = _pros.Records;
                pnlSearch.Visible     = true;
                ltSearchDuration.Text = "搜索用时:" + _pros.SearchDuration.ToString() + "秒。";
            }
        }
        if (prods == null || prods.Count == 0)
        {
            msgBox.ShowMsg("没有符合条件的产品存在!", System.Drawing.Color.Gray);
            return;
        }
        msgBox.HideMsg();
        bool islogin = Context.User.Identity.IsAuthenticated;
        if (orderBy == ProductOrderBy.Price)
        {
            prods.Sort(new SortProductByPrice(sortOrder,
                                              (islogin ? Profile.AccountInfo.UserID : 0),
                                              islogin
                                              ));
        }

        if (s == "grid")
        {
            dlProduct2.Visible      = false;
            dlProduct.Visible       = true;
            cpProduct.DataSource    = prods;
            cpProduct.BindToControl = dlProduct;
            dlProduct.DataSource    = cpProduct.DataSourcePaged;
            dlProduct.DataBind();
        }
        else
        {
            dlProduct.Visible       = false;
            dlProduct2.Visible      = true;
            cpProduct.DataSource    = prods;
            cpProduct.BindToControl = dlProduct2;
            dlProduct2.DataSource   = cpProduct.DataSourcePaged;
            dlProduct2.DataBind();
        }
        #endregion
    }
예제 #26
0
        public List <Productos> Get()
        {
            List <Productos> model = Products.GetProducts();

            return(model);
        }
예제 #27
0
    public List <Product> FindProducts(int categoryid = 0)
    {
        Products productManager = new Products();

        return(productManager.GetProducts(categoryid));
    }
예제 #28
0
 public IActionResult Delete(int id)
 {
     Products.GetProducts().Remove(Products.GetProducts().First(i => i.Id == id));
     return(Ok());
 }
예제 #29
0
 public static ObservableCollection <Product> FetchProducts()
 {
     return(Products.GetProducts());
 }
예제 #30
0
        // GET: Product
        public ActionResult Index()
        {
            Products prds = new Products();

            return(View(prds.GetProducts()));
        }