public override void Add(ITag entity) { Check.Argument.IsNotNull(entity, "entity"); Tag 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.Insert(tag); }
public override void Add(IStory entity) { Check.Argument.IsNotNull(entity, "entity"); Story 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); }
public override void Add(ICategory entity) { Check.Argument.IsNotNull(entity, "entity"); Category 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); }