<commit_before>﻿using System;
using System.Linq;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;

namespace Web.Models
{
    public static class SeedData
    {
        public static void EnsureSampleData(this IApplicationBuilder app)
        {
            var context = (ApplicationDbContext) app.ApplicationServices
                .GetService(typeof (ApplicationDbContext));

            var userManager = (UserManager<ApplicationUser>) app.ApplicationServices
                .GetService(typeof (UserManager<ApplicationUser>));

            // add a test user

            var defaultUser = new ApplicationUser
            {
                UserName = "<EMAIL>",
                Email = "<EMAIL>"
            };

            if (!context.Users.Any())
            {
                userManager
                    .CreateAsync(defaultUser, "<PASSWORD>")
                    .Wait();
            }

            // add a library

            if (!context.DistributionGroups.Any())
            {
                var personalLibrary = new DistributionGroup
                {
                    CreatedByUserId = userManager.GetUserIdAsync(defaultUser).Result,
                    CreatedOn = DateTimeOffset.Now,
                    ModifiedOn = DateTimeOffset.Now,
                    Name = "Private"
                };

                context.DistributionGroups.Add(personalLibrary);
                context.SaveChanges();

                // give the default user full access to their private cabinet

                defaultUser.LibraryAccessList.Add(new DistributionRecipient
                {
                    DistributionGroupId = personalLibrary.Id,
                    Permissions = PermissionTypes.Full
                });
            }<commit_msg>Setting status on distribution group<commit_after>﻿using System;
using System.Linq;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;

namespace Web.Models
{
    public static class SeedData
    {
        public static void EnsureSampleData(this IApplicationBuilder app)
        {
            var context = (ApplicationDbContext) app.ApplicationServices
                .GetService(typeof (ApplicationDbContext));

            var userManager = (UserManager<ApplicationUser>) app.ApplicationServices
                .GetService(typeof (UserManager<ApplicationUser>));

            // add a test user

            var defaultUser = new ApplicationUser
            {
                UserName = "<EMAIL>",
                Email = "<EMAIL>"
            };

            if (!context.Users.Any())
            {
                userManager
                    .CreateAsync(defaultUser, "<PASSWORD>")
                    .Wait();
            }

            // add a library

            if (!context.DistributionGroups.Any())
            {
                var personalLibrary = new DistributionGroup
                {
                    CreatedByUserId = userManager.GetUserIdAsync(defaultUser).Result,
                    CreatedOn = DateTimeOffset.Now,
                    ModifiedOn = DateTimeOffset.Now,
                    Name = "Private",
                    Status = StatusTypes.Active
                };

                context.DistributionGroups.Add(personalLibrary);
                context.SaveChanges();

                // give the default user full access to their private cabinet

                defaultUser.LibraryAccessList.Add(new DistributionRecipient
                {
                    DistributionGroupId = personalLibrary.Id,
                    Permissions = PermissionTypes.Full
                });
            }
{'fraction_non_alphanumeric': 0.07436882546652031, 'fraction_numerical': 0.0, 'mean_word_length': 1.4846625766871167, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4523341', 'n_tokens_mistral': 810, 'n_tokens_neox': 751, 'n_words': 176}