<commit_before>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Text;

namespace Cards.Core
{
    public class CardRepository : ICardRepository
    {
        public Area CreateArea(Area area)
        {
            using (var db = new CardsDb())
            {
                var result = db.Areas.Add(area);
                db.SaveChanges();

                return result;
            }
        }

        public List<Area> FindAllArea()
        {
            using (var db = new CardsDb())
            {
                var areas = db.Areas.Include("Cards").Where(a => a.IsActive == true).ToList();
                
                //TODO find better solution
                areas.ForEach(a => a.Cards.RemoveAll(c => !c.IsActive));

                return areas;
            }
        }

        public Card CreateCard(Card card)
        {
            using (var db = new CardsDb())
            {
                var result = db.Cards.Add(card);
                db.SaveChanges();<commit_msg>sort by age, default<commit_after>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Text;

namespace Cards.Core
{
    public class CardRepository : ICardRepository
    {
        public Area CreateArea(Area area)
        {
            using (var db = new CardsDb())
            {
                var result = db.Areas.Add(area);
                db.SaveChanges();

                return result;
            }
        }

        public List<Area> FindAllArea()
        {
            using (var db = new CardsDb())
            {
                var areas = db.Areas.Include("Cards").Where(a => a.IsActive == true).ToList();
                
                //TODO find better solution
                areas.ForEach(a => a.Cards.RemoveAll(c => !c.IsActive));

                //sort
                areas.ForEach(a => a.Cards = a.Cards.OrderBy(c => c.CreatedDateUtc).ToList());

                return areas;
            }
        }

        public Card CreateCard(Card card)
        {
            using (var db = new CardsDb())
            {
                var result = db.Cards.Add(card);
                db.SaveChanges();
{'fraction_non_alphanumeric': 0.10714285714285714, 'fraction_numerical': 0.0, 'mean_word_length': 1.3859095688748686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '7567276', 'n_tokens_mistral': 634, 'n_tokens_neox': 601, 'n_words': 143}