public Category AddCategory(Category categoryData) { categoryData.Id = Guid.NewGuid().ToString(); var savedCategory = _repo.Create(categoryData); return(savedCategory); }
public Category AddCategory(Category categoryData) { categoryData.Id = Guid.NewGuid().ToString(); categoryData.DateCatAdded = DateTime.Now; _repo.Create(categoryData); return(categoryData); }
public void Create(Categories item) { var Data = categoriesRepository.FindLastCategoryID() + 1; item.CategoryID = Data; categoriesRepository.Create(item); }
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)); }
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)); }
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); }
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); }
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); }
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); }
public async Task AddNewCategory(Category category) { await _categoriesRepository.Create(category); }
public void Create(Categories model) { var repository = new CategoriesRepository(); repository.Create(model); }
public async Task <IActionResult> Create([FromBody] Category category) { var response = await _categories.Create(category); return(Ok(response)); }
public Category Create(Category newCategory) { return(_repo.Create(newCategory)); }