示例#1
0
        public async Task <ProductAttributeServiceModel> CreateProductAttributeAsync(CreateUpdateProductAttributeServiceModel model)
        {
            var productAttribute = new ProductAttribute
            {
                Order    = model.Order,
                SellerId = model.OrganisationId.Value
            };

            this.context.ProductAttributes.Add(productAttribute.FillCommonProperties());

            var productAttributeTranslation = new ProductAttributeTranslation
            {
                ProductAttributeId = productAttribute.Id,
                Name     = model.Name,
                Language = model.Language
            };

            this.context.ProductAttributeTranslations.Add(productAttributeTranslation.FillCommonProperties());

            await this.context.SaveChangesAsync();

            await this.RebuildCategorySchemasAsync(
                model.OrganisationId.Value,
                model.Language,
                model.Username);

            return(await this.GetProductAttributeByIdAsync(new GetProductAttributeByIdServiceModel
            {
                Id = productAttribute.Id,
                Language = model.Language,
                OrganisationId = model.OrganisationId,
                Username = model.Username
            }));
        }
 public static ProductAttributeTranslation CreateProductAttributeTranslation(string productAttributeName, string productAttributeTypeName, string languageId, global::Microsoft.Dynamics.DataEntities.ProductAttribute productAttribute)
 {
     ProductAttributeTranslation productAttributeTranslation = new ProductAttributeTranslation();
     productAttributeTranslation.ProductAttributeName = productAttributeName;
     productAttributeTranslation.ProductAttributeTypeName = productAttributeTypeName;
     productAttributeTranslation.LanguageId = languageId;
     if ((productAttribute == null))
     {
         throw new global::System.ArgumentNullException("productAttribute");
     }
     productAttributeTranslation.ProductAttribute = productAttribute;
     return productAttributeTranslation;
 }