public Article AddArticleFromModel(ArticleModel model)
        {
            var article = _articleModelService.GetArticleFromModel(model);

            _articleRepository.Insert(article);

            return(article);
        }
Exemple #2
0
        public SportArticle AddSportArticleFromModel(SportArticleModel model)
        {
            var sportArticle = GetSportArticleFromModel(model);

            _sportArticleRepository.Insert(sportArticle);

            return(sportArticle);
        }
Exemple #3
0
        public void AddNewCategoryAdFromModel(AdvertisingModel model)
        {
            var categoryAd = GetCategoryAdFromModel(model);

            if (categoryAdRepository.Set()
                .Any(al => al.AdvertisingId == model.AdvertisingId && al.CategoryId == model.CategoryId))
            {
                throw new ArgumentException($"CategoryAd in category {model.CategoryId} for advertising {model.AdvertisingId} already exists", nameof(model));
            }

            categoryAdRepository.Insert(categoryAd);
        }
Exemple #4
0
        public void AddNewAdvertisingLocalizationFromModel(AdvertisingModel model)
        {
            var advertisingLocalization = GetAdvertisingLocalizationFromModel(model);

            if (advertisingLocalizationRepository.Set()
                .Any(al => al.AdvertisingId == model.AdvertisingId && al.LanguageId == model.LanguageId))
            {
                throw new ArgumentException($"localization in language {model.LanguageId} for advertising {model.AdvertisingId} already exists", nameof(model));
            }

            advertisingLocalizationRepository.Insert(advertisingLocalization);
        }
        public Category AddCategoryFromModel(CategoryModel model)
        {
            var category = GetCategoryFromModel(model);

            if (_categoryRepository.Set().Any(a => a.Id == category.Id))
            {
                throw new ArgumentException($"Category with id {category.Id} is already taken", nameof(model));
            }

            _categoryRepository.Insert(category);

            return(category);
        }
Exemple #6
0
        public TeamLocalization AddNewTeamLocalizationFromModel(TeamModel model)
        {
            var team = GetTeamFromModel(model);

            var teamLocalization = GetTeamLocalizationFromModel(team, model);

            if (_teamLocalizationRepository.Set()
                .Any(al => al.TeamId == model.TeamId && al.LanguageId == model.LanguageId))
            {
                throw new ArgumentException($"localization in language {model.LanguageId} for team {model.TeamId} already exists", nameof(model));
            }
            _teamLocalizationRepository.Insert(teamLocalization);
            return(teamLocalization);
        }
Exemple #7
0
        public void AddNewConferenceLocalizationFromModel(ConferenceModel model)
        {
            var conference = GetConferenceById(model.ConferenceId);

            var conferenceLocalization = GetConferenceLocalizationFromModel(conference, model);

            if (_conferenceLocalizationRepository.Set()
                .Any(al => al.ConferenceId == model.ConferenceId && al.LanguageId == model.LanguageId))
            {
                throw new Exception($"localization in language {model.LanguageId} for conference {model.ConferenceId} already exists");
            }

            _conferenceLocalizationRepository.Insert(conferenceLocalization);
        }
        public ArticleLocalization AddNewArticleLocalizationFromModel(ArticleModel model)
        {
            var article = GetArticleById(model.ArticleId);

            var articleLocalization = _articleModelService.GetArticleLocalizationFromModel(article, model);

            if (_articleLocalizationRepository.Set()
                .Any(al => al.ArticleId == model.ArticleId && al.LanguageId == model.LanguageId))
            {
                throw new Exception($"localization in language {model.LanguageId} for article {model.ArticleId} already exists");
            }

            _articleLocalizationRepository.Insert(articleLocalization);

            return(articleLocalization);
        }
Exemple #9
0
        public MainArticle AddMainArticleFromModel(MainArticleModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var mainArticle = GetMainArticleFromModel(model);

            if (mainArticle.Show && !CheckMainArticleState())
            {
                throw new Exception($"can not add main article {mainArticle.ArticleId} - reached maximum count. Remove or hide any existing main articles");
            }

            _mainArticleRepository.Insert(mainArticle);

            return(mainArticle);
        }