示例#1
0
        public override void Add(ICategory entity)
        {
            Check.Argument.IsNotNull(entity, "entity");

            var category = (Category)entity;

            if (Database.CategoryDataSource.Any(c => c.Name == category.Name))
            {
                throw new ArgumentException("\"{0}\" category already exits. Specifiy a diffrent name.".FormatWith(category.Name), "entity");
            }

            category.UniqueName = UniqueNameGenerator.GenerateFrom(Database.CategoryDataSource, category.Name);

            base.Add(category);
        }
示例#2
0
        public override void Add(ITag entity)
        {
            Check.Argument.IsNotNull(entity, "entity");

            var tag = (Tag)entity;

            if (Database.TagDataSource.Any(t => t.Name == tag.Name))
            {
                throw new ArgumentException("\"{0}\" tag already exits. Specifiy a diffrent name.".FormatWith(tag.Name), "entity");
            }

            tag.UniqueName = UniqueNameGenerator.GenerateFrom(Database.TagDataSource, tag.Name);

            Database.InsertOnSubmit(tag);
        }
示例#3
0
        public override void Add(IStory entity)
        {
            Check.Argument.IsNotNull(entity, "entity");

            var story = (Story)entity;

            if (Database.StoryDataSource.Any(s => s.UrlHash == story.UrlHash))
            {
                throw new ArgumentException("\"{0}\" story with the same url already exits. Specifiy a diffrent url.".FormatWith(story.Url), "entity");
            }

            story.UniqueName = UniqueNameGenerator.GenerateFrom(Database.StoryDataSource, story.Title);

            base.Add(story);
        }