Exemple #1
0
        private void View_ProductEdit(object sender, EditProductEventArgs e)
        {
            var product = this.service.GetById(e.Model.Id);

            if (product != null)
            {
                product = this.SetupChanges(product, e);

                this.service.EditProduct(product);
            }
        }
Exemple #2
0
        private Models.Product SetupChanges(Models.Product product, EditProductEventArgs args)
        {
            if (!product.Category.Name.Equals(args.Model.Category))
            {
                var category = this.categoryService.GetCategoryByName(args.Model.Category) ??
                               this.categoryService.CreateCategory(args.Model.Category);

                product.Category = category;
            }

            product.Name          = args.Model.Name;
            product.ImageBuffer   = args.Model.ImageBuffer;
            product.ImageMimeType = args.Model.ImageMimeType;
            product.Maker         = args.Model.Maker;
            product.Price         = args.Model.Price;
            product.Volume        = args.Model.Volume;

            return(product);
        }