Пример #1
0
        //_____________________________________________________________________

        /// <summary>
        /// Gets the details of the particular product through its ProductId.
        /// </summary>
        /// <param name="productid"></param>
        /// <returns></returns>

        public static ProductCategoryRelation GetProduct(long productid)
        {
            MendixArtikelenService.ArtikelenServicePortTypeClient masClient = new MendixArtikelenService.ArtikelenServicePortTypeClient();
            masClient.Open();

            MendixArtikelenService.mfGetArtikelMetArtikelcodeResponse artikel =
                masClient.mfGetArtikelMetArtikelcode(new MendixArtikelenService.mfGetArtikelMetArtikelcode()
            {
                ArtikelCode = productid
            });

            ProductCategoryRelation pc = new ProductCategoryRelation();

            Product prod = new Product();

            Categories cat = new Categories();

            pc.product = new Product()
            {
                ProductId            = artikel.Artikel.Artikelcode,
                CategoryOmschrijving = artikel.Artikel.Artikel_Categorie.Categorie.Omschrijving,
                Price = Convert.ToDouble(artikel.Artikel.Verkoopprijs),
                ProductDescription = artikel.Artikel.Omschrijving,
                ProductName        = artikel.Artikel.Omschrijving,
                Picture            = artikel.Artikel.Artikel_Afbeelding.Afbeelding?.Contents == null
                    ? "noDetailPic.jpg"
                    : "detailPic" + artikel.Artikel.Artikelcode + ".jpg",
                PictureContent = artikel.Artikel.Artikel_Afbeelding.Afbeelding?.Contents
            };

            return(pc);
        }
Пример #2
0
        //_____________________________________________________________________

        /// <summary>
        /// This method is used to retrieve all the products from the database for display.
        /// </summary>
        /// <returns></returns>

        public static List <Product> GetProducts()
        {
            MendixArtikelenService.ArtikelenServicePortTypeClient masClient = new MendixArtikelenService.ArtikelenServicePortTypeClient();
            masClient.Open();

            MendixArtikelenService.mfGetArtikelenResponseArtikel[] artikels =
                masClient.mfGetArtikelen(new MendixArtikelenService.mfGetArtikelen()
            {
                PageSize = -1, OffSet = -1
            });

            var listOfProduct = new List <Product>();

            foreach (var artikel in artikels)
            {
                //var product = new Product()
                //{
                //    CategoryOmschrijving = artikel.Artikel_Categorie.Categorie.Omschrijving,
                //    ProductId = artikel.Artikelcode,
                //    ProductName = artikel.Omschrijving,
                //    Price = artikel.Verkoopprijs != null
                //                ? Convert.ToDouble(artikel.Verkoopprijs)
                //                : 0.00,
                //    Picture = "noDetailPic.jpg"

                //};
                var productCatRelation = GetProduct(Convert.ToInt16(artikel.Artikelcode));
                listOfProduct.Add(productCatRelation.product);
            }
            ;
            masClient.Close();
            return(listOfProduct);
        }