コード例 #1
0
        public Category AddCategory(Category categoryData)
        {
            categoryData.Id = Guid.NewGuid().ToString();
            var savedCategory = _repo.Create(categoryData);

            return(savedCategory);
        }
コード例 #2
0
 public Category AddCategory(Category categoryData)
 {
     categoryData.Id           = Guid.NewGuid().ToString();
     categoryData.DateCatAdded = DateTime.Now;
     _repo.Create(categoryData);
     return(categoryData);
 }
コード例 #3
0
        public void Create(Categories item)
        {
            var Data = categoriesRepository.FindLastCategoryID() + 1;

            item.CategoryID = Data;
            categoriesRepository.Create(item);
        }
コード例 #4
0
        public async Task <ActionResult <Categories> > PostCategories(Categories categories)
        {
            await Task.Run(() => _categoriesRepository.Create(categories));

            await Task.Run(() => _categoriesRepository.Save());

            return(CreatedAtAction("GetCategories", new { id = categories.IdCategory }, categories));
        }
コード例 #5
0
        public async Task <ActionResult <Categories> > Create([FromBody] Categories categories)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var result = await _categoriesRepository.Create(categories);

            return(CreatedAtAction("Create", new { id = result }, categories));
        }
コード例 #6
0
 public Category AddCategory(Category categoryData)
 {
     // var exists = _repo.GetCategoryByName(categoryData.Name); NOTE ADDED As per business logic, however it does not allow to test further if it has any duplicates.
     // if (exists != null)
     // {
     //   throw new Exception("This category alredy exists.");
     // }
     categoryData.Id = Guid.NewGuid().ToString();
     _repo.Create(categoryData);
     return(categoryData);
 }
コード例 #7
0
        public void TestCreate()
        {
            Categories model = new Categories()
            {
                CategoryID   = 6,
                CategoryName = "aaa"
            };
            CategoriesRepository Repository = new CategoriesRepository();

            Repository.Create(model);
            var result = Repository.GetByID(6);

            Assert.IsTrue(result.CategoryID == 6);
        }
コード例 #8
0
        public void CreateCategoriesTest()
        {
            User _user = new User
            {
                Name = "BigTestUser",
            };

            CategoriesRepository categoriesRepos = new CategoriesRepository(_connectionString);
            UsersRepository      userRepos       = new UsersRepository(_connectionString, categoriesRepos);

            User createdUser    = userRepos.Create(_user);
            var  categorForTest = categoriesRepos.Create(createdUser.Id, _user.Name + " categories");

            //_userIdForDelete.Add(createdUser.Id);


            var DBCategoriesrId = categoriesRepos.GetUserCategories(createdUser.Id).Single();

            Assert.AreEqual(categorForTest.Id, DBCategoriesrId.Id);
        }
コード例 #9
0
        public void ShouldCreateUserAndAddCategory()
        {
            //arrange
            var user = new User
            {
                Name = "test"
            };
            const string category = "testCategory";

            //act
            var categoriesRepository = new CategoriesRepository(ConnectionString);
            var usersRepository      = new UsersRepository(ConnectionString, categoriesRepository);

            user = usersRepository.Create(user);

            _tempUsers.Add(user.Id);

            categoriesRepository.Create(user.Id, category);
            user = usersRepository.Get(user.Id);

            //asserts
            Assert.AreEqual(category, user.Categories.Single().Name);
        }
コード例 #10
0
 public async Task AddNewCategory(Category category)
 {
     await _categoriesRepository.Create(category);
 }
コード例 #11
0
        public void Create(Categories model)
        {
            var repository = new CategoriesRepository();

            repository.Create(model);
        }
コード例 #12
0
        public async Task <IActionResult> Create([FromBody] Category category)
        {
            var response = await _categories.Create(category);

            return(Ok(response));
        }
コード例 #13
0
 public Category Create(Category newCategory)
 {
     return(_repo.Create(newCategory));
 }