<commit_before>﻿using Microsoft.AspNet.Http;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Hermes.DataAccess
{
    public abstract class ContentManager<TContent, TKey> : PersistentItemManager<TContent, TKey>, IContentManager<TContent, TKey>
        where TContent : class, IContent<TKey>
        where TKey : IEquatable<TKey>
    {
        public HermesErrorDescriber ErrorDescriber { get; } = new HermesErrorDescriber();

        public ContentManager(IContentStore<TContent, TKey> store, IHttpContextAccessor contextAccessor) : base(store, contextAccessor) { }

        #region Overridden Methods

        public override async Task<HermesResult> AddAsync(TContent item)
        {
            var result = DoesTitleExist(item.Title);

            if (result.Succeeded)
            {
                return await base.AddAsync(item);
            }

            return result;
        }

        public override async Task<HermesResult> UpdateAsync(TContent item)<commit_msg>generated a new slug in the ContentManager<commit_after>﻿using Microsoft.AspNet.Http;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Hermes.DataAccess
{
    public abstract class ContentManager<TContent, TKey> : PersistentItemManager<TContent, TKey>, IContentManager<TContent, TKey>
        where TContent : class, IContent<TKey>
        where TKey : IEquatable<TKey>
    {
        public HermesErrorDescriber ErrorDescriber { get; } = new HermesErrorDescriber();

        public ContentManager(IContentStore<TContent, TKey> store, IHttpContextAccessor contextAccessor) : base(store, contextAccessor) { }

        #region Overridden Methods

        public override async Task<HermesResult> AddAsync(TContent item)
        {
            var result = DoesTitleExist(item.Title);

            if (result.Succeeded)
            {
                item.Slug = await GenerateNewSlug(item.Title);
                return await base.AddAsync(item);
            }

            return result;
        }

        public override async Task<HermesResult> UpdateAsync(TContent item)
{'fraction_non_alphanumeric': 0.07925801011804384, 'fraction_numerical': 0.0, 'mean_word_length': 3.2, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5615077', 'n_tokens_mistral': 655, 'n_tokens_neox': 633, 'n_words': 154}