Exemplo n.º 1
0
 public DetailsModel(NotesApplication.Repo.NoteContext context)
 {
     _context = context;
 }
Exemplo n.º 2
0
 public EditModel(NotesApplication.Repo.NoteContext context)
 {
     _context = context;
 }
Exemplo n.º 3
0
 public CreateModel(NotesApplication.Repo.NoteContext context)
 {
     _context = context;
 }
Exemplo n.º 4
0
 public IndexModel(NotesApplication.Repo.NoteContext context)
 {
     _context = context;
 }
Exemplo n.º 5
0
        public static void Initialize(NoteContext context)
        {
            context.Database.EnsureCreated();

            if (context.Users.Any())
            {
                return;
            }

            var users = new User[]
            {
                new User {
                    Email = "*****@*****.**", Name = "Bob Barker", CreatedOn = DateTime.Parse("2018-04-28")
                },
                new User {
                    Email = "*****@*****.**", Name = "Ryan Reynolds", CreatedOn = DateTime.Parse("2018-04-29")
                },
                new User {
                    Email = "*****@*****.**", Name = "Sally Fields", CreatedOn = DateTime.Parse("2018-04-30")
                }
            };

            foreach (User u in users)
            {
                context.Users.Add(u);
            }
            context.SaveChanges();


            var notes = new Note[]
            {
                new Note {
                    Title = "Test 1", Notes = "Test 1", CategoryId = 1, userId = 1, IsDeleted = false
                },
                new Note {
                    Title = "Test 2", Notes = "Test 2", CategoryId = 2, userId = 2, IsDeleted = false
                },
                new Note {
                    Title = "Test 3", Notes = "Testing 3", CategoryId = 3, userId = 3, IsDeleted = false
                }
            };

            foreach (Note n in notes)
            {
                context.Notes.Add(n);
            }
            context.SaveChanges();

            var categories = new Category[]
            {
                new Category {
                    Name = "Pre-Calculus"
                },
                new Category {
                    Name = "Network Security"
                },
                new Category {
                    Name = "Internet Programming"
                }
            };

            foreach (Category c in categories)
            {
                context.Categories.Add(c);
            }
            context.SaveChanges();
        }