Esempio n. 1
0
        public async Task <ICollection <GetCategoryDto> > Add(string categoryName, string userId)
        {
            var newCategory = _categoryFactory.Create(categoryName, userId);
            await _categoryRepository.Add(newCategory);

            return(await GetAll(userId));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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);
        }