Esempio n. 1
0
        private Category GetCategoryViaSqlReader(IDataReader readerSource)
        {
            var receivedCategory   = _categoryBuilder.CreateCategory(Convert.ToString(readerSource["CategoryName"]));
            var receivedCategoryId = Convert.ToInt32(readerSource["CategoryId"]);

            _categoryBuilder.SetCategoryId(receivedCategory, receivedCategoryId);

            return(receivedCategory);
        }
        public AnswerStatus CreateCategory(CategoryDto categoryDTO, ICategoryRepository categoryRepository)
        {
            try
            {
                var blogRepository   = _repositoryFactory.CreateBlogRepository(categoryRepository.UnitOfWork);
                var categoryToCreate = _categoryBuilder.CreateCategory(categoryDTO.CategoryName);
                var categoryBlog     = blogRepository.GetEntityById(categoryDTO.RelatedTo.Id);
                _blogBuilder.SetBlogId(categoryBlog, categoryDTO.RelatedTo.Id);
                _categoryBuilder.SetBlogRelatedTo(categoryToCreate, categoryBlog);

                categoryRepository.CreateEntity(categoryToCreate);

                return(AnswerStatus.Successfull);
            }
            catch (Exception exc)
            {
                _logger.Log(exc.ToString());

                return(AnswerStatus.Failed);
            }
        }