<commit_before>namespace CountryFood.Data.Migrations
{
    using CountryFood.Models;
    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<ApplicationDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
        }

        protected override void Seed(ApplicationDbContext context)
        {
            if (context.Roles.Count() == 0)
            {
                this.SeedUsers(context);   
            }
        }

        private void SeedUsers(ApplicationDbContext context)
        {
            var UserManager = new UserManager<AppUser>(new UserStore<AppUser>(context));
            var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));

            string adminRole = "admin";
            string appUserRole = "appUser";
            string password = "<PASSWORD>";

            //Create Role Test and User Test
            RoleManager.Create(new IdentityRole(appUserRole));
            UserManager.Create(new AppUser()
            {
                UserName = "<EMAIL>",
                Email = "<EMAIL>"
            }, password);
            UserManager.Create(new AppUser()
            {
                UserName = "<EMAIL>",
                Email = "<EMAIL>"
            }, password);

            //Create Role Admin if it does not exist
            if (!RoleManager.RoleExists(adminRole))
            {
                var roleresult = RoleManager.Create(new IdentityRole(adminRole));
            }

            //Create User=Admin with password=<PASSWORD>
            var adminUser = new AppUser();
            adminUser.UserName = "<EMAIL>";
            adminUser.Email = "<EMAIL>";
            var adminresult = UserManager.Create(adminUser, password);

            //Add User Admin to Role Admin
            if (adminresult.Succeeded)
            {
                var result = UserManager.AddToRole(adminUser.Id, adminRole);
            }

            base.Seed(context);
        }
    }
}
<commit_msg>Seed categories and regions in db.<commit_after>namespace CountryFood.Data.Migrations
{
    using CountryFood.Models;
    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<ApplicationDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
        }

        protected override void Seed(ApplicationDbContext context)
        {
            if (context.Roles.Count() == 0)
            {
                this.SeedUsers(context);
            }

            if (context.Regions.Count() == 0)
            {
                this.SeedRegions(context);
            }

            if (context.Categories.Count() == 0)
            {
                this.SeedCategories(context);
            }

            base.Seed(context);
        }

        private void SeedUsers(ApplicationDbContext context)
        {
            var UserManager = new UserManager<AppUser>(new UserStore<AppUser>(context));
            var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));

            string adminRole = "admin";
            string appUserRole = "appUser";
            string password = "<PASSWORD>";

            //Create Role appUser and 2 users
            RoleManager.Create(new IdentityRole(appUserRole));
            UserManager.Create(new AppUser()
            {
                UserName = "<EMAIL>",
                Email = "<EMAIL>"
            }, password);
            UserManager.Create(new AppUser()
            {
                UserName = "<EMAIL>",
                Email = "<EMAIL>"
            }, password);

            //Create Role Admin if it does not exist
            if (!RoleManager.RoleExists(adminRole))
            {
                var roleresult = RoleManager.Create(new IdentityRole(adminRole));
            }

            //Create User=Admin with password=<PASSWORD>
            var adminUser = new AppUser();
            adminUser.UserName = "<EMAIL>";
            adminUser.Email = "<EMAIL>";
            var adminresult = UserManager.Create(adminUser, password);

            //Add User Admin to Role Admin
            if (adminresult.Succeeded)
            {
                var result = UserManager.AddToRole(adminUser.Id, adminRole);
            }
        }

        private void SeedRegions(ApplicationDbContext context)
        {
            var regions = new List<Region>()
            {
                new Region() { Name = "North-West"},
                new Region() { Name = "North-Central"},
                new Region() { Name = "North-East"},
                new Region() { Name = "South-East"},
                new Region() { Name = "South-Central"},
                new Region() { Name = "South-West"},
            };

            foreach (var region in regions)
            {
                context.Regions.Add(region);
            }
        }

        private void SeedCategories(ApplicationDbContext context)
        {
            var categories = new List<ProductCategory>
            {
                new ProductCategory{ Name = "Milk"},
                new ProductCategory{ Name = "Vegetables"},
                new ProductCategory{ Name = "Fruit"},
                new ProductCategory{ Name = "Herbs"},
                new ProductCategory{ Name = "Cans"},
                new ProductCategory{ Name = "Dry fruits & veggies"},
            };

            foreach (var category in categories)
            {
                context.Categories.Add(category);
            }
        }

        private void SeedVillages(ApplicationDbContext context)
        {
            var villages = new List<Village>(){
                new Village { Name = "Buhovo"},
                new Village { Name = "Muhovo"},
                new Village { Name = "Elhovo"},
                new Village { Name = "Gorni Lozen"},
                new Village { Name = "Dolni Lozen"},
                new Village { Name = "Brulino"},
            };
        }

    }
}

{'fraction_non_alphanumeric': 0.09587155963302753, 'fraction_numerical': 0.0007645259938837921, 'mean_word_length': 1.6007952286282305, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, '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': '5563164', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1557, 'n_words': 375}