コード例 #1
0
        public async static void Initialize(SicherheitCoreContext context)
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();


            var users = new List <User>();

            if (!context.Users.Any())
            {
                for (int i = 1; i <= 5; i++)
                {
                    User user = new User
                    {
                        EmailAddress = $"user{i}@testowy.pl",
                        Password     = "******",
                        Name         = $"Testowy user {i}"
                    };
                    users.Add(user);
                }
            }

            var r     = new Random();
            var tasks = new List <PlannedTask>();

            if (!context.Tasks.Any())
            {
                for (int i = 1; i <= 15; i++)
                {
                    var         rand = r.Next(0, 4);
                    PlannedTask task = new PlannedTask
                    {
                        Title    = $"Task {i}",
                        Priority = TaskPriority.Medium,
                        Deadline = new DateTime(2018, 03, i),
                        State    = TaskState.Active,
                        UserId   = users.ElementAt(rand).Id
                    };
                    tasks.Add(task);
                }
            }
            await context.Users.AddRangeAsync(users);

            await context.Tasks.AddRangeAsync(tasks);

            await context.SaveChangesAsync();
        }
コード例 #2
0
 public SqlTaskRepository(SicherheitCoreContext context) : base(context)
 {
 }
コード例 #3
0
 public SqlRepository(SicherheitCoreContext context)
 {
     this._context = context;
 }