示例#1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            CategoryRepository categoryRepository = new CategoryRepository();

            categoryRepository.CreateCategory(txtName.Text, txtDescription.Text, listView1);
            categoryRepository.Eraser(groupBox1);
        }
示例#2
0
        public void TestAddcategory()
        {
            var validCategory = new Category()
            {
                CategoryName = "Education",
                UrlSlug      = "education",
                Description  = "education news",
            };

            categoryRepository.CreateCategory(validCategory);
            Assert.AreEqual(4, categoryRepository.GetAllCategories().Count);
        }
        public async Task <IHttpActionResult> CreateCategory()
        {
            Category category = new Category()
            {
                Name    = "Building",
                Details = "Category for all the Building related odd jobs / services"
            };

            await _repo.CreateCategory(category);

            return(Ok(String.Format("The category {0} has been successfully created", category.Name)));
        }
        public async Task PostCategory_Success()
        {
            var dbContext = _fixture.Context;
            var category  = new Category {
                CategoryName = "Test category"
            };

            var repository = new CategoryRepository(dbContext);
            var result     = await repository.CreateCategory(category);

            Assert.True(result);
            Assert.NotEmpty(await repository.ReadAllCategory());
        }
示例#5
0
        public IActionResult Create(Category cgy)
        {
            try
            {
                _categoryRepository.CreateCategory(cgy);

                return(RedirectToAction("Index", new { id = cgy.Id }));
            }
            catch
            {
                return(View(cgy));
            }
        }
示例#6
0
        public ActionResult Create(Category model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _repo.CreateCategory(model);
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                // log
            }

            return(View(model));
        }
示例#7
0
 public CategoryDto CreateCategory(CategoryInputModel body)
 {
     return(_categoryRepo.CreateCategory(body));
 }
示例#8
0
 public int CreateCategory(CategoryInputModel category)
 {
     return(_categoryRepository.CreateCategory(category));
 }
 public CategoryDetailDto CreateCategory(CategoryInputModel model)
 {
     return(_categoryRepository.CreateCategory(model));
 }
 public ActionResult <Category> CreateCategory(Category category)
 {
     categoryRepository.CreateCategory(category);
     return(CreatedAtAction("GetCategory", new { id = category.Id }, category));
 }