Example #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);
        }
Example #2
0
        public ActionResult Edit(ProductCategoryRelation pcr, int id, HttpPostedFileBase file)
        {
            try
            {
                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    file.SaveAs(Server.MapPath("~/Images/" + fileName));
                    pcr.product.Picture = WebConfigurationManager.AppSettings["ImageUpload"] + fileName;
                }

                pcr.product.ProductId = id;

                pcr.categories            = LetsShopImplementation.GetCategoryIdByName(pcr.categories.CategoryName, pcr.categories.SubCategoryName);
                pcr.product.CategoryId    = pcr.categories.CategoryId;
                pcr.product.SubCategoryId = pcr.categories.SubCategoryId;

                LetsShopImplementation.UpdateProduct(pcr.product);

                //cache.Add("ProductData", LetsShopImplementation.GetProducts(),
                //                   CacheItemPriority.High, null, absolutetime);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Example #3
0
        public ActionResult CreateProduct(ProductCategoryRelation pcr, HttpPostedFileBase file)
        {
            try
            {
                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    file.SaveAs(Server.MapPath("~/Images/" + fileName));
                    pcr.product.Picture = WebConfigurationManager.AppSettings["ImageUpload"] + fileName;
                }
                else
                {
                    pcr.product.Picture = WebConfigurationManager.AppSettings["ImageUpload"] + "defaultimage.jpg";
                }


                pcr.categories            = LetsShopImplementation.GetCategoryIdByName(pcr.categories.CategoryName, pcr.categories.SubCategoryName);
                pcr.product.CategoryId    = pcr.categories.CategoryId;
                pcr.product.SubCategoryId = pcr.categories.SubCategoryId;

                LetsShopImplementation.CreateProduct(pcr.product);

                cache.Add("ProductData", LetsShopImplementation.GetProducts(),
                          CacheItemPriority.High, null, absolutetime);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, "UI Policy");
                if (rethrow)
                {
                    throw;
                }
                return(View());
            }
        }