public void AddCat()
        {
            Category junkCat = repo.GetAll().Categories.First();

            junkCat.CategoryId   = 0;
            junkCat.CategoryName = "Pr0n";

            CategoryResponse response = repo.Add(junkCat);

            Assert.AreEqual(true, response.Success);
        }
Exemple #2
0
        public CategoryResponse Add(Category category)
        {
            var context = new PersonalBlogEntities();

            if (context.Categories.Contains(category))
            {
                var response = new CategoryResponse();
                response.Success = false;
                response.Message = $"The category {category.CategoryName} is already in the database.";
                return(response);
            }
            else
            {
                return(repo.Add(category));
            }
        }