Exemple #1
0
        public void CreateArticle(ArticleDTO data)
        {
            DateTime currentTime = DateTime.Now;

            Article article = new Article()
            {
                Title           = data.Title,
                Text            = data.Text,
                ClientProfileId = data.AuthorId,
                TimeCreated     = currentTime,
                TimeEdited      = currentTime
            };

            foreach (var tag in data.Tags)
            {
                Tag dbtag = _uow.Tags.Get(tag.Id);
                if (dbtag == null)
                {
                    throw new ValidationException("There is no tag with such id.", "TagIds");
                }
                article.Tags.Add(dbtag);
            }

            _uow.Save();
        }
Exemple #2
0
        public void CreateCategory(Category category)
        {
            var count = _blogUnitOfWork.CategoryRepository.GetCount(x => x.Name == category.Name);

            if (count > 0)
            {
                throw new DuplicationException("Category Name already exists", nameof(category.Name));
            }

            _blogUnitOfWork.CategoryRepository.Add(category);
            _blogUnitOfWork.Save();
        }
        public void CreateSetting(Setting setting)
        {
            var count = _blogUnitOfWork.SettingRepository.GetCount(x => x.Title == setting.Title);

            if (count > 0)
            {
                throw new DuplicationException("Setting title already exists", nameof(setting.Title));
            }

            _blogUnitOfWork.SettingRepository.Add(setting);
            _blogUnitOfWork.Save();
        }
Exemple #4
0
        public void CreateBook(Book book)
        {
            var count = _blogUnitOfWork.BookRepository.GetCount(x => x.Title == book.Title);

            if (count > 0)
            {
                throw new DuplicationException("Book title already exists", nameof(book.Title));
            }

            _blogUnitOfWork.BookRepository.Add(book);
            _blogUnitOfWork.Save();
        }
Exemple #5
0
        public void CreateAbout(About ab)
        {
            var count = _blogUnitOfWork.AboutRepository.GetCount(x => x.Title == ab.Title);

            if (count > 0)
            {
                throw new DuplicationException("Title already exists", nameof(ab.Title));
            }

            _blogUnitOfWork.AboutRepository.Add(ab);
            _blogUnitOfWork.Save();
        }
Exemple #6
0
 public void CreateComment(Comment comment)
 {
     _blogUnitOfWork.CommentRepository.Add(comment);
     _blogUnitOfWork.Save();
 }
Exemple #7
0
 public void CreateCompose(BlogComposes blogComposes)
 {
     _blogUnitOfWork.BlogRepository.Add(blogComposes);
     _blogUnitOfWork.Save();
 }
Exemple #8
0
 public void CreateItemCategory(ItemCategory category)
 {
     _blogUnitOfWork.ItemCategoryRepository.Add(category);
     _blogUnitOfWork.Save();
 }