Ejemplo n.º 1
0
        public void Add(ICategory entity)
        {
            Check.Argument.IsNotNull(entity, "entity");

            var category = (Category)entity;

            if (_context.Categories.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(_context.Categories, category.Name);

            base.Add(category);
        }
Ejemplo n.º 2
0
        public void Add(IStory entity)
        {
            Check.Argument.IsNotNull(entity, "entity");

            var story = (Story)entity;

            if (_context.Stories.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(_context.Stories, story.Title);

            base.Add(story);
        }
Ejemplo n.º 3
0
        public void Add(ITag entity)
        {
            Check.Argument.IsNotNull(entity, "entity");

            Tag tag = (Tag)entity;

            if (_context.Tags.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(_context.Tags, tag.Name);

            base.Add(tag);
        }