예제 #1
0
        public static NewsAuthor CreateNewsAuthorAndSave()
        {
            NewsAuthor newNewsAuthor = new NewsAuthor()
            {
                Name = SetInformation.SetName()
            };

            TableDataService <NewsAuthor> dataService = new TableDataService <NewsAuthor>();

            if (dataService.GetAll().All(newsAuthor => newsAuthor.Name != newNewsAuthor.Name))
            {
                dataService.Add(newNewsAuthor);
                return(newNewsAuthor);
            }

            throw new Exception("This news author already exists");
        }
예제 #2
0
        public static CommentAuthor CreateCommentAuthorAndSave()
        {
            CommentAuthor newCommentAuthor = new CommentAuthor()
            {
                Name = SetInformation.SetName()
            };

            TableDataService <CommentAuthor> dataService = new TableDataService <CommentAuthor>();

            if (dataService.GetAll().All(commentAuthor => commentAuthor.Name != newCommentAuthor.Name))
            {
                dataService.Add(newCommentAuthor);
                return(newCommentAuthor);
            }

            throw new Exception("This comment author already exists");
        }
예제 #3
0
        public static Theme CreateThemeAndSave()
        {
            Theme newTheme = new Theme()
            {
                Name = SetInformation.SetName()
            };

            TableDataService <Theme> dataService = new TableDataService <Theme>();

            if (dataService.GetAll().All(theme => theme.Name != newTheme.Name))
            {
                dataService.Add(newTheme);
                return(newTheme);
            }

            throw new Exception("This theme already exists");
        }