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); } }
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); } }
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); } }
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); } }