Beispiel #1
0
        private void UpdateProductImages( Product product, ProductModel model )
        {
            product.ProductImages.ToList().ForEach( s => s.IsDeleted = true );

            if ( model.ProductImageModels != null )
            {
                foreach ( ProductImageModel productImageModel in model.ProductImageModels )
                {
                    ProductImage productImage = product.ProductImages.FirstOrDefault( s => s.UploadId == productImageModel.UploadId );

                    if ( productImage == null )
                    {
                        productImage = new ProductImage();
                        productImage.Initialise();

                        productImage.UploadId = productImageModel.UploadId;

                        product.ProductImages.Add( productImage );
                    }

                    productImage.Ordinal = productImageModel.Ordinal;
                    productImage.IsDeleted = false;
                }
            }
        }
        public ProductsListItemModel( Product product )
        {
            AutoMap.Map( product, this );

            this.IsInStock = ( product.StockCount > 0 );

            this.ImageLocation = product.ProductImages.First().Upload.PhysicalLocation;
        }
Beispiel #3
0
        private SaveResult UpdateProduct( Product product, ProductModel model, ContentManagementDb db )
        {
            if ( UserSession.Current.IsAdministrator == false )
                return SaveResult.AccessDenied;

            if ( UserSession.Current.CurrentDomain( db ).CanAccess( product ) == false )
                return SaveResult.IncorrectDomain;

            try
            {
                AutoMap.Map( model, product );
                product.UpdateTimeStamp();

                UpdateProductImages( product, model );

                db.SaveChanges();

                return SaveResult.Success;
            }
            catch// ( Exception ex )
            {
                return SaveResult.Fail;
            }
        }
 public ProductsListItemModel( Product product )
 {
     AutoMap.Map( product, this );
     this.CategoryName = product.ProductCategory.Name;
 }
 public ProductDetailsModel( Product product )
 {
     AutoMap.Map( product, this );
 }