コード例 #1
0
 public void Add(Category entity)
 {
     entity.Username = common.GetCurrentUsername();
     categoryRepository.Add(entity);
     Save();
 }
コード例 #2
0
 public void Add(Category category)
 {
     categoryRepository.Add(category);
 }
コード例 #3
0
 public void CreateCategory(Category category)
 {
     _categoryRepository.Add(category);
     SaveCategory();
 }
コード例 #4
0
ファイル: CategoryService.cs プロジェクト: wind89/KmgMarket
 public async Task <Guid> Add(AddCategoryViewModel model)
 {
     return(await _categoryRepository.Add(model));
 }
コード例 #5
0
        public void CreateCategory(CategoryViewModel categoryDTO)
        {
            var category = Mapper.Map <CategoryViewModel, Category>(categoryDTO);

            categorysRepository.Add(category);
        }
コード例 #6
0
 public async Task <Category> Add([FromBody] CategoryInput category)
 {
     return(await repo.Add(category));
 }
コード例 #7
0
        public (string, Category) Post([FromBody] Category category)
        {
            _db.Add(category);

            return($"/api/categories/{category.Id}", category);
        }
コード例 #8
0
 protected override void Preparation()
 {
     m_CategoryRepository = ObjectFactory.GetInstance<ICategoryRepository>();
     m_Category = new Category { Id = 0, Name = "Figur", Description = "Alle Figuren" };
     m_Id = m_CategoryRepository.Add(m_Category);
     m_Category = m_CategoryRepository.GetById(m_Id);
     m_Category.Name = "Test";
     m_Category.Description = "Test";
     Because();
 }
コード例 #9
0
        public ActionResult Edit(int Id, string name, string desc, string descSec, decimal price, string cat, double disc, HttpPostedFileBase image)
        {
            var viewModel = new ProductViewModel
            {
                Id                = Id,
                Name              = name,
                Category          = cat,
                Description       = desc,
                DescriptionSecond = descSec,
                Price             = price,
            };

            var masterModel = new MasterPageModel();

            _categoryRepository.GetAll();
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    viewModel.ImageMimeType = image.ContentType;
                    viewModel.ImageData     = new byte[image.ContentLength];
                    image.InputStream.Read(viewModel.ImageData, 0, image.ContentLength);
                }
                else
                {
                    var tmp = _repository.Get(p => p.Id == viewModel.Id);
                    viewModel.ImageData     = tmp.ImageData;
                    viewModel.ImageMimeType = tmp.ImageMimeType;
                }
                var product = new Product();
                if (_create)
                {
                    viewModel.ProductViewModelToEntity(product, _categoryRepository, _unitOfWork);
                    _repository.Add(product);
                }
                else
                {
                    product = _repository.Get(p => p.Id == viewModel.Id);
                    viewModel.ProductViewModelToProductEntity(product);

                    var category = product.Category;

                    if (category.Name != viewModel.Category)
                    {
                        var newCategory = _categoryRepository.Get(c => c.Name == viewModel.Category);
                        if (newCategory != null)
                        {
                            product.Category = newCategory;
                        }
                        else
                        {
                            var tmp = new Category {
                                Name = viewModel.Category
                            };
                            _categoryRepository.Add(tmp);
                            _unitOfWork.Commit();
                            product.Category = tmp;
                        }
                        _unitOfWork.Commit();
                    }
                    _repository.Update(product);
                }
                _unitOfWork.Commit();
                TempData["Message"] = string.Format("{0} has been saved", product.Name);
                return(RedirectToAction("Index"));
            }
            else
            {
                masterModel.ProductView = viewModel;
                return(View(masterModel));
            }
        }
コード例 #10
0
 public ResultMessage <Category> Add(Category data)
 {
     return(repository.Add(data));
 }
コード例 #11
0
 public async Task AddToDb(Category category)
 {
     await _categoryRepository.Add(category);
 }
コード例 #12
0
 public int AddCategory(Category category)
 {
     _categoryRepository.Add(category);
     return(category.Id);
 }
コード例 #13
0
        public void Add(CategoryDTO categoryDTO)
        {
            var category = Mapper.Map <Category> (categoryDTO);

            _categoryRepository.Add(category);
        }
コード例 #14
0
 public void CreateCategory(CategoryDto categoryDto)
 {
     //var category = categoryDto.MappingCategory();
     categoryRepository.Add(categoryDto.MappingCategory());
 }
コード例 #15
0
ファイル: CategoryController.cs プロジェクト: Nidhi27/BlogApp
 public Category PostCategories(Category category)
 {
     return(repository.Add(category));
 }
コード例 #16
0
 public bool Add(Category category)
 {
     return(_repo.Add(category));
 }
コード例 #17
0
        public void Store(CategoryDto categoryDto)
        {
            var category = new Category(categoryDto.name);

            CategoryRepository.Add(category);
        }
コード例 #18
0
        public CategoryDTO Add(CategoryDTO categoryDTO)
        {
            var category = categoryDTO.ToModel();

            category.Id      = IdentityGenerator.NewSequentialGuid();
            category.Created = DateTime.UtcNow;
            if (category.Parent == null || category.Parent.Id == Guid.Empty)
            {
                category.Depth = 1;
            }
            else
            {
                category.Parent = _Repository.Get(categoryDTO.Parent.Id);
                category.Depth  = category.Parent.Depth + 1;
            }

            if (category.Name.IsNullOrBlank())
            {
                throw new DefinedException(CommonMessageResources.Name_Empty);
            }

            if (_Repository.Exists(category))
            {
                throw new DataExistsException(string.Format(BaseMessagesResources.Category_Exists_WithValue, category.Name));
            }

            if (category.Parent != null)
            {
                var rulePrefix = category.Parent.ChildSnRulePrefix;
                if (rulePrefix.IsNullOrBlank())
                {
                    throw new DefinedException(BaseMessagesResources.Category_Parent_SerialNumberRule_Prefix_Empty);
                }
                var ruleNumberLength = category.Parent.ChildSnRuleNumberLength;
                if (ruleNumberLength <= 0)
                {
                    throw new DefinedException(BaseMessagesResources.Category_Parent_SerialNumberRule_NumberLength_NotGreat_Than_Zero);
                }
                category.Sn = SerialNumberGenerator.GetSerialNumber(rulePrefix, false, ruleNumberLength);
            }
            else
            {
                var ruleName = CommonMessageResources.SerialNumberRule_Category;
                var snRule   = SerialNumberRuleQuerier.FindBy(ruleName);
                if (snRule == null)
                {
                    throw new DataNotFoundException(string.Format(BaseMessagesResources.SerialNumberRule_NotExists_WithValue, ruleName));
                }
                category.Sn = SerialNumberGenerator.GetSerialNumber(snRule.Prefix, snRule.UseDateNumber, snRule.NumberLength);
            }
            _Repository.Add(category);

            #region 操作日志

            var categoryDto = category.ToDto();

            OperateRecorder.RecordOperation(categoryDto.Sn,
                                            BaseMessagesResources.Add_Category,
                                            categoryDto.GetOperationLog());

            #endregion

            //commit the unit of work
            _Repository.UnitOfWork.Commit();

            return(category.ToDto());
        }
コード例 #19
0
 public void Add(Category obj)
 {
     _repository.Add(obj);
 }
コード例 #20
0
        public bool Add(CategoryDTO category)
        {
            var categoryEntity = mapper.Map <CategoryDTO, Category>(category);

            return(_categoryRepository.Add(categoryEntity));
        }
コード例 #21
0
 public ServiceResult Add(Category category)
 {
     category.Id = default;
     _categoryRepository.Add(category);
     return(ServiceResult.Success());
 }
コード例 #22
0
        public async Task <int> Add(Category entity)
        {
            var category = Mapper.Map <Category, CategoryDAOEntity>(entity);

            return(await _categoryRepository.Add(category));
        }
コード例 #23
0
 public Category Add(Category entity)
 {
     return(_categoryRepository.Add(entity));
 }
コード例 #24
0
ファイル: CategoryService.cs プロジェクト: nixelt/news
 public void CreateCategory(Category category)
 {
     _categoryRepository.Add(category);
     _unitOfWork.Commit();
 }
コード例 #25
0
 public void Add(Category entity)
 {
     categoryRepository.Add(entity);
 }
コード例 #26
0
 public void Insert(CategoryViewModel ViewModel)
 {
     _repository.Add(_mapper.Map <Category>(ViewModel));
 }
コード例 #27
0
        public async Task <ActionResult> Post(Category category)
        {
            await categoryRepository.Add(category);

            return(CreatedAtAction("Get", new { id = category.Id }, category));
        }
コード例 #28
0
 public void CreateCategory(Category category)
 {
     categorysRepository.Add(category);
 }
コード例 #29
0
 public void Add(CategoryDTO entity)
 {
     _categoryRepository.Add(entity);
 }
コード例 #30
0
 public void Insert(Category entity)
 {
     _categoryRepository.Add(entity);
 }
コード例 #31
0
 public Category Post(Category category)
 {
     return(categoryRepository.Add(category));
 }