Ejemplo n.º 1
0
        public void AddNewCategory(ProductCategory productCategory)
        {
            try
            {
                productCategory.CreateDate = DateTime.Now;

                _categoryRepository.Add(productCategory);
                //_uow.Save();
            }
            catch (Exception ex)
            {
                throw new Exception("Failed adding the category", ex);
            }
        }
Ejemplo n.º 2
0
        public void UpdateCategory(ProductCategory category)
        {
            try
            {
                //ProductCategory category = _categoryRepository.GetAll().FirstOrDefault(i => i.Id == id);
                category.UpdateDate = DateTime.Now;
                //category.DepartmentId = 1;

                _categoryRepository.Update(category);
                _uow.Save();
            }
            catch (Exception ex)
            {
                throw new Exception("Failed updating the category", ex);
            }
        }
Ejemplo n.º 3
0
        public void AddNewProduct(Product product, ProductCategory category)
        {
            try
            {
                //var existCategory = new ProductCategory()
                //{
                //    Id = category.Id
                //}; // _categoryRepository.GetAll().Where(i => i.Id == category.Id);

                //product.ProductCategories.Add(existCategory);

                product.ProductCategories.Add(category);

                _productRepository.Add(product, category);
                //_uow.Save();

            }
            catch (Exception ex)
            {
                throw new Exception("Failed adding the product", ex);
            }
        }
Ejemplo n.º 4
0
        public void AddCategory(ProductCategory category)
        {
            var newCategory = new ProductCategory();

            if (ModelState.IsValid)
            {
                newCategory.ProductCategoryName = category.ProductCategoryName;
                newCategory.ProductCategoryDesc = category.ProductCategoryDesc;
                newCategory.ProductCategoryImgSamllUrl = "/Content/Assets/Images/category_default_sm.png";
                newCategory.ProductCategoryImgLargeUrl = "/Content/Assets/Images/category_default_lg.png";
                newCategory.Notes = "";
                newCategory.DepartmentId = 1;
                newCategory.CreateDate = DateTime.Now;
                newCategory.UpdateDate = DateTime.Now;

                _categoryService.AddNewCategory(newCategory);
            }
        }