<commit_before>﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using AutoMapper;
using OnTheRoad.Data.Models;
using OnTheRoad.Domain.Models;
using OnTheRoad.Domain.Repositories;
using OnTheRoad.Data.Contracts;

namespace OnTheRoad.Data.Repositories
{
    public abstract class BaseRepository<EntityType, DomainType> : IGetRepository<DomainType>, IModifyRepository<DomainType>
        where EntityType : BaseEntity
        where DomainType : IIdentifiable
    {
        public BaseRepository(IOnTheRoadDbContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context cannot be null!");
            }

            this.Context = context;
            this.DbSet = this.Context.Set<EntityType>();
        }

        protected IOnTheRoadDbContext Context { get; }

        protected DbSet<EntityType> DbSet { get; }

        public virtual void Add(DomainType model)
        {
            this.SetEntityState(model, EntityState.Added);
        }

        public virtual void Delete(DomainType model)
        {
            this.SetEntityState(model, EntityState.Deleted);
        }

        public virtual IEnumerable<DomainType> GetAll()
        {
            var mapped = new List<DomainType>();
            foreach (var entity in this.DbSet.ToList())
            {
                mapped.Add(this.MapEntityToDomain(entity));
            }

            return mapped;
        }

        public virtual DomainType GetById(object id)
        {
            var found = this.DbSet.Find(id);
            var mapped = this.MapEntityToDomain(found);

            return mapped;
        }

        public virtual void Update(DomainType model)<commit_msg>set properties set t Context and DbSet<commit_after>﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using AutoMapper;
using OnTheRoad.Data.Models;
using OnTheRoad.Domain.Models;
using OnTheRoad.Domain.Repositories;
using OnTheRoad.Data.Contracts;

namespace OnTheRoad.Data.Repositories
{
    public abstract class BaseRepository<EntityType, DomainType> : IGetRepository<DomainType>, IModifyRepository<DomainType>
        where EntityType : BaseEntity
        where DomainType : IIdentifiable
    {
        public BaseRepository(IOnTheRoadDbContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context cannot be null!");
            }

            this.Context = context;
            this.DbSet = this.Context.Set<EntityType>();
        }

        protected IOnTheRoadDbContext Context { get; private set; }

        protected DbSet<EntityType> DbSet { get; private set; }

        public virtual void Add(DomainType model)
        {
            this.SetEntityState(model, EntityState.Added);
        }

        public virtual void Delete(DomainType model)
        {
            this.SetEntityState(model, EntityState.Deleted);
        }

        public virtual IEnumerable<DomainType> GetAll()
        {
            var mapped = new List<DomainType>();
            foreach (var entity in this.DbSet.ToList())
            {
                mapped.Add(this.MapEntityToDomain(entity));
            }

            return mapped;
        }

        public virtual DomainType GetById(object id)
        {
            var found = this.DbSet.Find(id);
            var mapped = this.MapEntityToDomain(found);

            return mapped;
        }

        public virtual void Update(DomainType model)
{'fraction_non_alphanumeric': 0.08083076059500421, 'fraction_numerical': 0.0, 'mean_word_length': 2.1849865951742626, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '527124', 'n_tokens_mistral': 949, 'n_tokens_neox': 904, 'n_words': 221}