Beispiel #1
0
        private static void SaveMarks(EditProduct editProduct, int productID)
        {
            var curList = ProductMarks.GetByProductID(productID);

            foreach (var mark in editProduct.Marks)
            {
                if (!curList.Any(item => item.ID == mark.ID))
                {
                    var productMark = Mapper.Map <ProductMark>(mark);

                    productMark.ProductID = productID;

                    ProductMarks.Insert(productMark);
                }
                else
                {
                    ProductMarks.Update(mark);
                    curList.Remove(curList.Single(cls => cls.ID == mark.ID));
                }
            }

            foreach (var item in curList)
            {
                ProductMarks.Delete(item.ID);
            }
        }
Beispiel #2
0
        public ActionResult Edit(int?id)
        {
            EditProduct editProduct;

            if (id.HasValue)
            {
                editProduct = Mapper.Map <EditProduct>(Products.GetByID(id.Value));

                editProduct.Text               = HttpUtility.HtmlDecode(editProduct.Text);
                editProduct.GroupUrlPerfix     = Groups.GetByID(editProduct.GroupID.Value).UrlPerfix;
                editProduct.Groups             = ProductGroups.GetByProductID(editProduct.ID).Select(item => item.GroupID).ToList();
                editProduct.Images             = ProductImages.GetByProductID(editProduct.ID);
                editProduct.Files              = ProductFiles.GetByProductID(editProduct.ID);
                editProduct.Marks              = ProductMarks.GetByProductID(editProduct.ID);
                editProduct.Points             = ProductPoints.GetByProductID(editProduct.ID);
                editProduct.Keywords           = ProductKeywords.GetByProductID(editProduct.ID);
                editProduct.Notes              = ProductNotes.GetByProductID(editProduct.ID);
                editProduct.ProductPricesLinks = ProductPricesLinks.GetByProductID(editProduct.ID);

                editProduct.Supplies = ProductSupplies.GetByProductID(editProduct.ID);
                editProduct.Prices   = ProductPrices.GetByProductID(editProduct.ID);
                editProduct.Varients = ProductVarients.GetByProductID(editProduct.ID);

                editProduct.Discounts = ProductDiscounts.GetAllByProductID(editProduct.ID);
            }
            else
            {
                editProduct        = new EditProduct();
                editProduct.userID = UserID;
            }

            return(View(editProduct));
        }