상속: System.Web.UI.Page
        public async Task WHEN_product_has_NO_variant_and_is_NOT_in_discount_SHOULD_return_regular_price()
        {
            // Arrange
            const bool hasVariants = false;
            var        provider    = _container.CreateInstance <FromPriceProvider>();

            var document = new ProductDocument
            {
                PropertyBag   = new PropertyBag(),
                EntityPricing = new EntityPricing()
                {
                    RegularPrice = 15,
                    CurrentPrice = 15
                }
            };

            // Act
            var priceSearchViewModel = await provider.GetPriceAsync(hasVariants, document);

            // Assert
            priceSearchViewModel.HasPriceRange.Should().BeFalse();
            priceSearchViewModel.IsOnSale.Should().BeFalse();
            priceSearchViewModel.ListPrice.Should().Be(15);
            priceSearchViewModel.Price.Should().Be(null);
            priceSearchViewModel.DisplayPrice.Should().NotBeNullOrEmpty();
            priceSearchViewModel.DisplaySpecialPrice.Should().Be(null);
        }
예제 #2
0
        private static bool HasVariants(ProductDocument resultItem)
        {
            if (resultItem == null)
            {
                return(false);
            }
            if (resultItem.PropertyBag == null)
            {
                return(false);
            }

            object variantCountObject;

            if (!resultItem.PropertyBag.TryGetValue("GroupCount", out variantCountObject))
            {
                return(false);
            }

            if (variantCountObject == null)
            {
                return(false);
            }

            var variantCountString = variantCountObject.ToString();

            int result;

            int.TryParse(variantCountString, out result);

            return(result > 1); // If the document has only one variant then server returns EntityPrice instead of GroupPrice
        }
        public async Task WHEN_product_has_variants_and_at_least_one_in_discount_AND_all_variants_regular_prices_are_NOT_the_same_AND_all_variant_discount_prices_are_NOT_the_same_SHOULD_return_FROM_minimum_price2()
        {
            // Arrange
            const bool hasVariants = true;
            var        provider    = _container.CreateInstance <FromPriceProvider>();

            var document = new ProductDocument
            {
                PropertyBag = new PropertyBag
                {
                    { FromPriceProvider.GroupCurrentPriceFromProperty, 44.99 },
                    { FromPriceProvider.GroupCurrentPriceToProperty, 49.99 },
                    //Improbable but we cover this case
                    { FromPriceProvider.GroupRegularPriceFromProperty, 39.99 },
                    { FromPriceProvider.GroupRegularPriceToProperty, 54.99 }
                }
            };

            // Act
            var priceSearchViewModel = await provider.GetPriceAsync(hasVariants, document);

            // Assert
            priceSearchViewModel.HasPriceRange.Should().BeTrue();
            priceSearchViewModel.IsOnSale.Should().BeTrue();
            priceSearchViewModel.ListPrice.Should().Be(null);
            priceSearchViewModel.Price.Should().Be(39.99);
            priceSearchViewModel.DisplayPrice.Should().Be(null);
            priceSearchViewModel.DisplaySpecialPrice.Should().NotBeNullOrEmpty();
        }
예제 #4
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        #region 获得用户选择集
        /// <summary>
        /// 获得用户选择集
        /// </summary>
        /// <returns></returns>
        public void GetSelect(ProductDocument CatDocument, ref Selection SelectArc, Form form)
        {
            if (CatDocument == null)
            {
                MessageBox.Show("仿真环境未初始化!请先用工具栏初始化命令初始化运行环境!");
                return;
            }
            form.WindowState = FormWindowState.Minimized;
            SelectArc        = CatDocument.Selection;
            SelectArc.Clear();
            var Result = SelectArc.SelectElement3(InputObjectType(4), "请选择曲面", true, CATMultiSelectionMode.CATMultiSelTriggWhenSelPerf, false);

            if (Result == "Cancel")
            {
                return;
            }
            if (SelectArc.Count < 1)
            {
                MessageBox.Show("请先选择对象后再点此命令!");
                return;
            }
            form.WindowState   = FormWindowState.Normal;
            form.StartPosition = FormStartPosition.CenterScreen;

            return;
        }
        protected virtual async Task <bool> GetProductSearchViewModelAvailableForSell(
            ProductSearchViewModel productSearchViewModel,
            ProductDocument productDocument)
        {
            if (productSearchViewModel.HasVariants)
            {
                return(true);
            }

            _productSettings = await ProductSettings.GetProductSettings(ComposerContext.Scope, ComposerContext.CultureInfo).ConfigureAwait(false);

            if (!_productSettings.IsInventoryEnabled)
            {
                return(true);
            }

            var availableStatusesForSell = ComposerConfiguration.AvailableStatusForSell;

            return((from inventoryItemAvailability
                    in productDocument.InventoryLocationStatuses
                    from inventoryItemStatuse
                    in inventoryItemAvailability.Statuses
                    select GetInventoryItemStatus(inventoryItemStatuse.Status))
                   .Any(inventoryItemStatus => availableStatusesForSell
                        .Any(availableStatusForSell => availableStatusForSell == inventoryItemStatus)));
        }
        private static bool IsInDiscount(ProductDocument document)
        {
            var listPrice = GetPriceForComparison(document.EntityPricing.RegularPrice.GetValueOrDefault(0));
            var price     = GetPriceForComparison(document.EntityPricing.CurrentPrice.GetValueOrDefault(0));

            return(listPrice > price);
        }
        private static bool AreAllVariantDiscountPriceTheSame(ProductDocument document)
        {
            var fromDiscountPrice = GetPriceForComparison(GetFromDiscountPrice(document) ?? 0);
            var toDiscountPrice   = GetPriceForComparison(GetToDiscountPrice(document) ?? 0);

            return(fromDiscountPrice == toDiscountPrice);
        }
        /// <summary>
        /// Deep load all ProductDocument children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock           = CreateMockInstance(tm);
                mockCollection = DataRepository.ProductDocumentProvider.GetPaged(tm, 0, 10, out count);

                DataRepository.ProductDocumentProvider.DeepLoading += new EntityProviderBaseCore <ProductDocument, ProductDocumentKey> .DeepLoadingEventHandler(
                    delegate(object sender, DeepSessionEventArgs e)
                {
                    if (e.DeepSession.Count > 3)
                    {
                        e.Cancel = true;
                    }
                }
                    );

                if (mockCollection.Count > 0)
                {
                    DataRepository.ProductDocumentProvider.DeepLoad(tm, mockCollection[0]);
                    System.Console.WriteLine("ProductDocument instance correctly deep loaded at 1 level.");

                    mockCollection.Add(mock);
                    // DataRepository.ProductDocumentProvider.DeepSave(tm, mockCollection);
                }

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
예제 #9
0
 public void SetApplication(INFITF.Application APP, Document CatDoc, ProductDocument CatADoc, Documents CatDocs)
 {
     CatApplication = APP;
     CatActiveDoc   = CatADoc;
     CatDocument    = CatDoc;
     CatDocuments   = CatDocs;
 }
 internal Response <int> ProductDocumentSave(ProductDocument entity, int languageId, long userId, string auditWorkstation)
 {
     try
     {
         int newId = 0;
         if (entity.Id == 0)
         {
             newId = _documentManagement.ProductDocumentCreate(entity, userId, auditWorkstation);
         }
         else
         {
             newId = _documentManagement.ProductDocumentUpdate(entity, userId, auditWorkstation);
         }
         return(new Response <int>(newId, ResponseType.SUCCESSFUL,
                                   string.Empty,
                                   string.Empty));
     }
     catch (Exception ex)
     {
         log.Error(ex);
         return(new Response <int>(0, ResponseType.ERROR,
                                   "Error processing request, please try again.",
                                   log.IsDebugEnabled || log.IsTraceEnabled ? ex.Message : ""));
     }
 }
        ///<summary>
        ///  Returns a Typed ProductDocument Entity with mock values.
        ///</summary>
        static public ProductDocument CreateMockInstance_Generated(TransactionManager tm)
        {
            ProductDocument mock = new ProductDocument();

            mock.ModifiedDate = TestUtility.Instance.RandomDateTime();

            //OneToOneRelationship
            Document mockDocumentByDocumentId = DocumentTest.CreateMockInstance(tm);

            DataRepository.DocumentProvider.Insert(tm, mockDocumentByDocumentId);
            mock.DocumentId = mockDocumentByDocumentId.DocumentId;
            //OneToOneRelationship
            Product mockProductByProductId = ProductTest.CreateMockInstance(tm);

            DataRepository.ProductProvider.Insert(tm, mockProductByProductId);
            mock.ProductId = mockProductByProductId.ProductId;

            // create a temporary collection and add the item to it
            TList <ProductDocument> tempMockCollection = new TList <ProductDocument>();

            tempMockCollection.Add(mock);
            tempMockCollection.Remove(mock);


            return((ProductDocument)mock);
        }
예제 #12
0
        public ActionResult ProductDocumentsCreate(int productID)
        {
            var productDocument = new ProductDocument();

            productDocument.ProductID = productID;
            return(View(productDocument));
        }
        protected static bool HasVariants(ProductDocument resultItem)
        {
            if (resultItem == null)
            {
                return(false);
            }
            if (resultItem.PropertyBag == null)
            {
                return(false);
            }

            object variantCountObject;

            if (!resultItem.PropertyBag.TryGetValue("GroupCount", out variantCountObject))
            {
                return(false);
            }

            if (variantCountObject == null)
            {
                return(false);
            }

            var variantCountString = variantCountObject.ToString();

            int result;

            int.TryParse(variantCountString, out result);

            return(result > 0);
        }
예제 #14
0
        public void SaveCgrToProject(string docName)
        {
            Documents       docs    = myCATIA.Documents;
            ProductDocument prodDoc = (ProductDocument)docs.Add("Product");
            Product         prod    = prodDoc.Product;
            Products        prods   = prod.Products;
            Array           arr     = Array.CreateInstance(typeof(object), 1);

            arr.SetValue(docName + ".cgr", 0);
            prods.AddComponentsFromFiles(arr, "All");

            string dir  = docName.Substring(0, docName.LastIndexOf('\\') + 1);
            string name = docName.Substring(docName.LastIndexOf('\\') + 1);

            docName = dir + RemoveDiacritics(name);
            prodDoc = (ProductDocument)myCATIA.ActiveDocument;
            if (System.IO.File.Exists(docName + ".CATProduct"))
            {
                System.IO.File.Delete(docName + ".CATProduct");
            }
            try
            {
                prodDoc.SaveAs(docName + ".CATProduct");
            }
            catch (Exception)
            {
                Console.WriteLine("CGR document '" + docName +
                                  "' could not be saved as CATProduct.");
            }
            if (prodDoc != null)
            {
                prodDoc.Close();
            }
        }
예제 #15
0
        public bool InitCATIAProduct(bool bNewProduct, string strProduct)
        {
            if (bNewProduct)
            {
                //初始化
                docCATIA    = CATIA.Documents;
                oProductDoc = (ProductDocument)docCATIA.Add("Product");
            }
            else
            {
                if (strProduct.Trim() == "")
                {
                    oProductDoc = (ProductDocument)CATIA.ActiveDocument;
                    if (oProductDoc == null)
                    {
                        docCATIA    = CATIA.Documents;
                        oProductDoc = (ProductDocument)docCATIA.Add("Product");
                    }
                }
                else
                {
                    if (System.IO.File.Exists(strProduct)) //有文件
                    {
                        oProductDoc = (ProductDocument)CATIA.Documents.Open(strProduct);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        public async Task WHEN_product_has_variant_and_has_NO_variants_in_discount_AND_all_variants_regular_prices_are_the_same_SHOULD_return_regular_price()
        {
            // Arrange
            const bool hasVariants = true;
            var        provider    = _container.CreateInstance <FromPriceProvider>();

            var document = new ProductDocument
            {
                PropertyBag = new PropertyBag
                {
                    { FromPriceProvider.GroupCurrentPriceFromProperty, 49.99 },
                    { FromPriceProvider.GroupCurrentPriceToProperty, 49.99 },
                    { FromPriceProvider.GroupRegularPriceFromProperty, 49.99 },
                    { FromPriceProvider.GroupRegularPriceToProperty, 49.99 }
                }
            };

            // Act
            var priceSearchViewModel = await provider.GetPriceAsync(hasVariants, document);

            // Assert
            priceSearchViewModel.HasPriceRange.Should().BeFalse();
            priceSearchViewModel.IsOnSale.Should().BeFalse();
            priceSearchViewModel.ListPrice.Should().Be(49.99);
            priceSearchViewModel.Price.Should().Be(null);
            priceSearchViewModel.DisplayPrice.Should().NotBeNullOrEmpty();
            priceSearchViewModel.DisplaySpecialPrice.Should().Be(null);
        }
예제 #17
0
        public async Task <bool> Index(ProductDocument document)
        {
            await CreateIndexIfNeeded(_indexName);

            var response = await _client.IndexDocumentAsync(document);

            return(response.IsValid);
        }
        private static double?GetToRegularPrice(ProductDocument document)
        {
            var propertyBag = document.PropertyBag;

            return(propertyBag.ContainsKey(GroupRegularPriceToProperty) ?
                   Convert.ToDouble(propertyBag[GroupRegularPriceToProperty]) :
                   (double?)null);
        }
예제 #19
0
        public static List <Product> GetSubProduct(this ProductDocument i)
        {
            // TODO: FIX
            throw new NotImplementedException();

            // var products = i.GetProduct().Products;
            // return products;
        }
        private static string GetPriceListId(ProductDocument document)
        {
            var propertyBag = document.PropertyBag;

            return(propertyBag.ContainsKey(CurrentPricePriceListIdProperty) ?
                   propertyBag[CurrentPricePriceListIdProperty].ToString() :
                   null);
        }
        private static double?GetFromDiscountPrice(ProductDocument document)
        {
            var propertyBag = document.PropertyBag;

            return(propertyBag.ContainsKey(GroupCurrentPriceFromProperty) ?
                   Convert.ToDouble(propertyBag[GroupCurrentPriceFromProperty]) :
                   (double?)null);
        }
예제 #22
0
        ///<summary>
        ///  Update the Typed ProductDocument Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, ProductDocument mock)
        {
            ProductDocumentTest.UpdateMockInstance_Generated(tm, mock);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);
        }
예제 #23
0
        private static bool HasOneOrMoreVariantInDiscount(ProductDocument document)
        {
            var fromDiscountPrice = GetPriceForComparison(GetFromDiscountPrice(document) ?? 0);
            var toDiscountPrice   = GetPriceForComparison(GetToDiscountPrice(document) ?? 0);
            var fromRegularPrice  = GetPriceForComparison(GetFromRegularPrice(document) ?? 0);
            var toRegularPrice    = GetPriceForComparison(GetToRegularPrice(document) ?? 0);

            return(fromDiscountPrice < fromRegularPrice || toDiscountPrice < toRegularPrice);
        }
예제 #24
0
        /// <summary>
        /// 初始化CATIA环境并获取信息到全局变量
        /// </summary>
        /// <returns></returns>
        private bool InitCatEnv()
        {
            try
            {
                CatApplication = (INFITF.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Catia.Application");
            }
            catch (Exception)
            {
                this.WindowState   = FormWindowState.Normal;
                this.StartPosition = FormStartPosition.CenterScreen;
                MessageBox.Show("未检测到打开的CATIA!,请重新运行CATIA!");
                return(false);
                //throw;
            }
            CatApplication.set_Caption("正在运行瑞祥快速建模工具!");
            // 获取当前活动ProductDocument
            try
            {
                CatDocument = (ProductDocument)CatApplication.ActiveDocument;
            }
            catch (Exception)
            {
                CatDocument = (ProductDocument)CatApplication.Documents.Add("Product");
                try
                {
                    CatDocument.Product.set_PartNumber("RxProduct");
                }
                catch (Exception)
                {
                    MessageBox.Show("未检测到活动Product,正在为您创建,请手动辅助完成!");
                    return(false);
                }
                //MessageBox.Show("未检测到活动Product,已自动为您创建对象!");
            }
            // 添加一个新零件
            string Name = "RXFastDesignTool";

            try
            {
                PartID = ((PartDocument)CatApplication.Documents.Item(Name + ".CATPart")).Part;
            }
            catch (Exception)
            {
                try
                {
                    CatDocument.Product.Products.AddNewComponent("Part", Name);
                }
                catch (Exception)
                {
                    return(false);
                    // throw;
                }
                PartID = ((PartDocument)CatApplication.Documents.Item(Name + ".CATPart")).Part;
            }
            return(true);
        }
예제 #25
0
        public async Task <ActionResult> ProductDocumentsDelete(int id)
        {
            ProductDocument productDocument = await productDocumentService.FindProductDocumentsByIDAsync(id);

            if (productDocument == null)
            {
                return(HttpNotFound());
            }
            return(View(productDocument));
        }
예제 #26
0
        public async Task <ActionResult> ProductDocumentsCreate([Bind(Include = "ProductDocumentID,ProductID, Description")] ProductDocument productDocument, HttpPostedFileBase documentFiles)
        {
            if (ModelState.IsValid)
            {
                await productDocumentService.CreateAsync(productDocument, documentFiles);

                return(RedirectToAction("Index"));
            }
            return(View());
        }
        public ProductDocument ToProductDocument(Document document)
        {
            if (document == null)
            {
                return(null);
            }
            var productDoc = new ProductDocument();

            if (document.PropertyBag != null)
            {
                productDoc.PropertyBag = new PropertyBag(document.PropertyBag);

                if (document.PropertyBag.ContainsKey(nameof(productDoc.Id)))
                {
                    productDoc.Id = (string)document.PropertyBag[nameof(productDoc.Id)];
                }
                if (document.PropertyBag.ContainsKey(nameof(productDoc.CatalogId)))
                {
                    productDoc.CatalogId = (string)document.PropertyBag[nameof(productDoc.CatalogId)];
                }
                if (document.PropertyBag.ContainsKey(nameof(productDoc.ProductId)))
                {
                    productDoc.ProductId = (string)document.PropertyBag[nameof(productDoc.ProductId)];
                }
                if (document.PropertyBag.ContainsKey(nameof(productDoc.Sku)))
                {
                    productDoc.Sku = (string)document.PropertyBag[nameof(productDoc.Sku)];
                }

                productDoc.InventoryLocationStatuses = new List <InventoryItemAvailability>();

                //Legacy pricing fields

                #pragma warning disable 612, 618
                if (document.PropertyBag.ContainsKey(nameof(productDoc.CurrentPrice)) && document.PropertyBag[nameof(productDoc.CurrentPrice)] != null)
                {
                    productDoc.CurrentPrice = double.Parse(document.PropertyBag[nameof(productDoc.CurrentPrice)].ToString());
                }
                if (document.PropertyBag.ContainsKey(nameof(productDoc.DefaultPrice)) && document.PropertyBag[nameof(productDoc.DefaultPrice)] != null)
                {
                    productDoc.DefaultPrice = double.Parse(document.PropertyBag[nameof(productDoc.DefaultPrice)].ToString());
                }
                if (document.PropertyBag.ContainsKey(nameof(productDoc.RegularPrice)) && document.PropertyBag[nameof(productDoc.RegularPrice)] != null)
                {
                    productDoc.RegularPrice = double.Parse(document.PropertyBag[nameof(productDoc.RegularPrice)].ToString());
                }
                #pragma warning restore 612, 618

                //New pricing fields
                productDoc.EntityPricing = document.PropertyBag.GetOrDeserializePropertyBagEntity <EntityPricing>(nameof(ProductDocument.EntityPricing));
                productDoc.GroupPricing  = document.PropertyBag.GetOrDeserializePropertyBagEntity <GroupPricing>(nameof(ProductDocument.GroupPricing));
            }

            return(productDoc);
        }
 private ProductPriceSearchViewModel CreateOneOrMoreVariantInDiscountPrice(ProductDocument document)
 {
     if (AreAllVariantRegularPriceTheSame(document))
     {
         return(CreateAllVariantRegularPriceTheSamePrice(document));
     }
     else
     {
         return(CreateNotAllVariantRegularPriceTheSamePrice(document));
     }
 }
 private ProductPriceSearchViewModel GetProductPriceWithVariant(ProductDocument document)
 {
     if (HasOneOrMoreVariantInDiscount(document))
     {
         return(CreateOneOrMoreVariantInDiscountPrice(document));
     }
     else
     {
         return(CreateNoVariantInDiscountPrice(document));
     }
 }
예제 #30
0
 public ActionResult Edit([Bind(Include = "ProductID,ModifiedDate,isDeleted")] ProductDocument productDocument)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productDocument).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductID = new SelectList(db.Products, "ProductID", "Name", productDocument.ProductID);
     return(View(productDocument));
 }
 /// <summary>
 /// There are no comments for ProductDocument in the schema.
 /// </summary>
 public void AddToProductDocument(ProductDocument productDocument)
 {
     base.AddObject("ProductDocument", productDocument);
 }
 /// <summary>
 /// Create a new ProductDocument object.
 /// </summary>
 /// <param name="productID">Initial value of ProductID.</param>
 /// <param name="documentID">Initial value of DocumentID.</param>
 /// <param name="modifiedDate">Initial value of ModifiedDate.</param>
 public static ProductDocument CreateProductDocument(int productID, int documentID, global::System.DateTime modifiedDate)
 {
     ProductDocument productDocument = new ProductDocument();
     productDocument.ProductID = productID;
     productDocument.DocumentID = documentID;
     productDocument.ModifiedDate = modifiedDate;
     return productDocument;
 }