Пример #1
0
 public static ProductAttribute ToEntity(this ProductAttributeDto model)
 {
     return(model.MapTo <ProductAttributeDto, ProductAttribute>());
 }
Пример #2
0
        public virtual async Task <ProductAttributeDto> InsertOrUpdateProductAttribute(ProductAttributeDto model)
        {
            if (string.IsNullOrEmpty(model.Id))
            {
                model = await InsertProductAttribute(model);
            }
            else
            {
                model = await UpdateProductAttribute(model);
            }

            return(model);
        }
        public ActionResult Update(ProductAttributeDto dto)
        {
            var result = _productattributeContract.Update(dto);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
 public static ProductAttribute ToEntity(this ProductAttributeDto model, ProductAttribute destination)
 {
     return(model.MapTo(destination));
 }
Пример #5
0
        public ProductDto GenerateProduct(long num, int numberOfProductToGenerate)
        {
            ProductDto aProduct = new ProductDto();
            IList <ProductAttributeDto> aProductAttributeList = new List <ProductAttributeDto>();;
            ProductAttributeDto         aProductAttributes    = null;
            StringBuilder longdescription        = new StringBuilder();;
            StringBuilder debugLogAttributesList = new StringBuilder();
            StringBuilder debutLogStringBuilder  = new StringBuilder();


            if (isLoggingDebug)
            {
                Debug.WriteLine(String.Format("{0}Creating Random category, and random corresponding product... {1}/{2} - {3}", debugPrefix, num, numberOfProductToGenerate, DateTime.Now));
            }

            /// Generate randomly a category
            RandomizeCategory();
            RandomizeProductName();
            aProduct.Name = string.Concat(productNameCurrentName);

            if (isLoggingDebug && isLoggingVerbose)
            {
                Debug.WriteLine(String.Format("{0}Initializing a random price between 1 and 10 000", debugPrefix));
            }
            aProduct.Price = priceRdm.Next(1, 10000);

            if (isLoggingDebug && isLoggingVerbose)
            {
                Debug.WriteLine(String.Format("{0}Creating some random short description...", debugPrefix));
            }
            RandomizeAdjectives();
            RandomizeShortQual();
            aProduct.ShortDescription = string.Concat(adjectivesCurrentName, " ", shortQualCurrentName, "{", callType, "#", num, "}");

            #region DescriptionLongue

            if (isLoggingDebug && isLoggingVerbose)
            {
                Debug.WriteLine(string.Concat(debugPrefix, "Creating some random long description..."));
            }
            RandomizeVerbs();
            RandomizeAdjectives();
            RandomizeCOD();
            longdescription.Append("<b>Ceci est une description vraiment extrêmement longue...!</b ><br/>");
            for (int j = 0; j < 10; j++)
            {
                longdescription.AppendLine(string.Format("{0} {1} {2} {3} {4} <br/>", longDescriptionPrefix, productNameCurrentName,
                                                         verbsCurrentName, adjectivesCurrentName, codNameCurrentName));
            }
            aProduct.Description = longdescription.ToString();

            #endregion

            if (isLoggingDebug && isLoggingVerbose)
            {
                Debug.WriteLine(string.Concat(debugPrefix, "Choosing some random address..."));
            }
            RandomizeProductAddress();
            aProduct.AdressOneLine = productAddressCurrentAddress;
            aProduct.Country       = productAddressCurrentCountryCode;
            aProduct.Latitude      = Decimal.Parse(productAddressCurrentLatitude, NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint | NumberStyles.Float, CultureInfo.InvariantCulture);
            aProduct.Longitude     = Decimal.Parse(productAddressCurrentLongitude, NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint | NumberStyles.Float, CultureInfo.InvariantCulture);

            if (isLoggingDebug && isLoggingVerbose)
            {
                Debug.WriteLine(string.Concat(debugPrefix, "Assigning category..."));
            }
            aProduct.CategoryId = Int32.Parse(categoryCurrentID) + 1; // offset in database

            if (isLoggingDebug && isLoggingVerbose)
            {
                Debug.WriteLine(string.Concat(debugPrefix, "Generating product's ", numberOfAttributeItemNamesPerCategory, " characteristics: 2-tuple Attribute-type / Attribute-item..."));
            }

            debugLogAttributesList = new StringBuilder();
            for (int k = 0; k < numberOfAttributeItemNamesPerCategory; k++)
            {
                aProductAttributes = new ProductAttributeDto();

                if (isLoggingDebug && isLoggingVerbose)
                {
                    Debug.WriteLine(string.Concat(debugPrefix, "Generating product's characteristics...", k + 1, "/", numberOfAttributeItemNamesPerCategory));
                }
                GetAttributeTypeNameForCategory(Int32.Parse(categoryCurrentID), k);
                RandomizeAttributeItem(Int32.Parse(categoryCurrentID), k);
                aProductAttributes.Type = attTypeCurrentValue;
                aProductAttributes.Item = attItemCurrentValue;

                if (isLoggingDebug && isLoggingVerbose)
                {
                    debugLogAttributesList.Append(string.Concat("[AttributeType=", attTypeCurrentValue, "]|[AttributeItem=", attItemCurrentValue, "]"));
                }
                if (isLoggingDebug && isLoggingVerbose)
                {
                    Debug.WriteLine(string.Concat(debugPrefix, "Adding product's characteristics...", k + 1, "/", numberOfAttributeItemNamesPerCategory));
                }

                aProductAttributeList.Add(aProductAttributes);
            }
            if (isLoggingDebug && isLoggingProductFullDetailsOnCreation)
            {
                Debug.WriteLine(String.Format("{0} This is a random Category attribute type |ID={1}|CategoryName={2}|Offset={3}|AttributeTypeName={4}|AttributeItemName({5})={6}|", debugPrefix, categoryCurrentID, categoryCurrentName, num.ToString(), attTypeCurrentValue, attItemCurrentCol.ToString(), attItemCurrentValue));
            }
            //Debug.WriteLine(debugPrefix + string.Concat("This is a random Category attribute type [ID=", categoryCurrentID, "|CategoryName=", categoryCurrentName, "|Offset=", v, "|AttributeTypeName=", attTypeCurrentValue, "|AttributeItemName(", attItemCurrentCol, ")=", attItemCurrentValue, "]"));
            aProduct.ProductAttributes = aProductAttributeList;

            if (isLoggingDebug)
            {
                Debug.WriteLine(String.Format("{0}Created Product name: \"{1}\"", debugPrefix, aProduct.Name));
            }

            return(aProduct);
        }