예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task AddCategoryAsync(CategoryInput input)
        {
            var category = input.MapTo <Category>();

            if (input.Id.HasValue)
            {
                category             = _categoryRepository.Get(input.Id.Value);
                category.Description = input.Description;
                category.Name        = input.Name;
                category.Sort        = input.Sort;
                FileRelationRepository.Delete(x => x.KeyId == input.Id && x.ModuleId == ModuleType.Category);
            }
            else
            {
                await _categoryRepository.InsertAsync(category);

                CurrentUnitOfWork.SaveChanges();
            }
            //  await AddFileRelationAsync(input.FileId, category.Id, ModuleType.Category);
        }
예제 #2
0
        /// <summary>
        /// 添加产品
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task AddProductAsync(ProductInput input)
        {
            var product = input.MapTo <Product>();

            if (input.Id.HasValue)
            {
                product             = _productRepository.Get(input.Id.Value);
                product.CategoryId  = input.CategoryId;
                product.Description = input.Description;
                product.Name        = input.Name;
                product.Package     = input.Package;
                product.Sort        = input.Sort;
                FileRelationRepository.Delete(x => x.KeyId == input.Id.Value && (x.ModuleId == ModuleType.ProductMan || x.ModuleId == ModuleType.ProductDetail));
            }
            else
            {
                product = _productRepository.Insert(product);
                CurrentUnitOfWork.SaveChanges();
            }
            await AddFileRelationAsync(input.ProductImage, product.Id, ModuleType.ProductMan);
            await AddFileRelationAsync(input.StyleImage, product.Id, ModuleType.ProductDetail);
        }