public async Task <ICollection <GetCategoryDto> > Add(string categoryName, string userId) { var newCategory = _categoryFactory.Create(categoryName, userId); await _categoryRepository.Add(newCategory); return(await GetAll(userId)); }
public CategoryDto CreateNewCategory(SecurityContext securityContext, NewCategoryMessage newCategoryMessage) { if (newCategoryMessage == null) { throw new ArgumentNullException(nameof(newCategoryMessage)); } var category = _categoryFactory.Create( newCategoryMessage.Name, _noteFactory, _subscriberFactory ); category = _categoryRepository.Add(category); return(_mapper.Map <CategoryDto>(category)); }
private async Task <Category> GetCategoryByName(string name, string userId) { var category = await _categoryRepository.GetByName(name, userId); if (category == null) { category = _categoryFactory.Create(name, userId); await _categoryRepository.Add(category); } return(category); }