예제 #1
0
        public int CreateNewCategory(CategoryInputModel category)
        {
            var slug = category.Name.ToLower().Replace(" ", "-");

            Console.WriteLine(slug);
            category.Slug = slug;

            return(_categoryRepository.CreateNewCategory(category));
        }
예제 #2
0
        public void SaveCategoryTestContext()
        {
            Category C = new Category("Testcategory", 1);

            C.CategoryDesc = "Testcategorydesc";
            C.CategoryImg  = "NoImage.jpg";

            CatRepoTest.CreateNewCategory(C);
            var TotalCategories = CatRepoTest.RetrieveAllCategories();

            Assert.IsTrue(TotalCategories.Count > 4);
        }
예제 #3
0
        public ActionResult Add(CategoryViewModel model, string uploadedImage)
        {
            var c = new Category(model.CategoryName, 1);

            c.CategoryDesc = model.CategoryDesc;

            if (c.CategoryDesc == null)
            {
                c.CategoryDesc = "No description";
            }
            c.CategoryImg = uploadedImage;
            if (categoryRep.CreateNewCategory(c))
            {
                return(RedirectToAction("Overview", "Category"));
            }

            return(RedirectToAction("Overview", "Category"));
        }
 public CategoryDto CreateNewCategory(CategoryInputModel category)
 {
     return(_categoryRepository.CreateNewCategory(category));
 }