Ejemplo n.º 1
0
        protected void InitializeProductFile(ProductFile file, bool updateFileName)
        {
            if (updateFileName)
            {
                ProductFile otherFile = null;
                if (_currentMode == Mode.DropDownList)
                {
                    otherFile     = HccApp.CatalogServices.ProductFiles.Find(FilesDropDownList.SelectedValue);
                    file.StoreId  = otherFile.StoreId;
                    file.Bvin     = otherFile.Bvin;
                    file.FileName = otherFile.FileName;
                }
                else if (_currentMode == Mode.FileBrowsed)
                {
                    otherFile     = HccApp.CatalogServices.ProductFiles.Find(FileIdHiddenField.Value);
                    file.StoreId  = otherFile.StoreId;
                    file.Bvin     = otherFile.Bvin;
                    file.FileName = otherFile.FileName;
                }
                else if (_currentMode == Mode.NewUpload)
                {
                    file.FileName = Path.GetFileName(NewFileUpload.FileName);
                }
            }
            else
            {
                if (_currentMode == Mode.NewUpload)
                {
                    file.FileName = Path.GetFileName(NewFileUpload.FileName);
                }
            }

            if (DisplayShortDescription)
            {
                file.ShortDescription = ShortDescriptionTextBox.Text.Trim();
            }

            if (ProductId != string.Empty)
            {
                file.ProductId = ProductId;
                file.SetMinutes(AvailableForTimespanPicker.Months, AvailableForTimespanPicker.Days,
                                AvailableForTimespanPicker.Hours, AvailableForTimespanPicker.Minutes);
                if (NumberOfDownloadsTextBox.Text.Trim() != string.Empty)
                {
                    file.MaxDownloads = int.Parse(NumberOfDownloadsTextBox.Text);
                }
                else
                {
                    file.MaxDownloads = 0;
                }
            }
        }
        protected void ProductsGridView_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
        {
            if (Page.IsValid)
            {
                string key = (string)ProductsGridView.DataKeys[e.RowIndex].Value;
                ProductFile file = MTApp.CatalogServices.ProductFiles.FindByBvinAndProductBvin((string)ViewState["id"], key);

                GridViewRow row = ProductsGridView.Rows[e.RowIndex];
                TextBox tb = (TextBox)row.FindControl("MaxDownloadsTextBox");
                BVAdmin_Controls_TimespanPicker tp = (BVAdmin_Controls_TimespanPicker)row.FindControl("TimespanPicker");

                if (tb != null)
                {
                    int val = 0;
                    if (int.TryParse(tb.Text, out val))
                    {
                        file.MaxDownloads = val;
                    }
                    else
                    {
                        file.MaxDownloads = 0;
                    }
                }

                if (tp != null)
                {
                    file.SetMinutes(tp.Months, tp.Days, tp.Hours, tp.Minutes);
                }

                if (MTApp.CatalogServices.ProductFiles.Update(file))
                {
                    MessageBox1.ShowOk("File was successfully updated!");
                }
                else
                {
                    MessageBox1.ShowError("File update failed. Unknown error.");
                }
                BindProductsGrid();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the product file.
        /// </summary>
        //[TestMethod]
        public void AddProductFile()
        {
            var pfile   = _irepoproductfile.GetAddProductFile();
            var prj     = GetRootProduct();
            var filelst = new List <ProductFile>();

            foreach (var file in pfile.Select(productFile => _applicationDB.CatalogServices.ProductFiles.FindByFileNameAndDescription(productFile.FileName, productFile.ShortDescription).FirstOrDefault()))
            {
                if (file == null)
                {
                    var newfile = new ProductFile
                    {
                        StoreId          = _application.CurrentStore.Id,
                        ProductId        = prj.Bvin,
                        MaxDownloads     = 0,
                        FileName         = "test.jpg",
                        ShortDescription = "test.jpg",
                    };
                    newfile.SetMinutes(2, 2, 2, 4);
                    filelst.Add(newfile);
                }
                else
                {
                    file.StoreId      = _application.CurrentStore.Id;
                    file.ProductId    = prj.Bvin;
                    file.MaxDownloads = 0;
                    file.SetMinutes(2, 2, 2, 4);
                    filelst.Add(file);
                }
            }

            //Act/Assert
            foreach (var productFile in filelst)
            {
                Assert.IsTrue(_application.CatalogServices.ProductFiles.Create(productFile));
            }
        }