Exemple #1
0
 public EditModel(StoreApp.Data.StoreAppContext context)
 {
     _context = context;
 }
Exemple #2
0
        public static void Initialize(StoreAppContext context)
        {
            context.Database.EnsureCreated();

            // Look for any users.
            if (context.Users.Any())
            {
                return;   // DB has been seeded
            }

            var users = new User[]
            {
                new User {
                    Name = "Jim Fig", Address = "Portlaw, Co. Waterford", Nationality = "Irish"
                },
                new User {
                    Name = "Jane Doe", Address = "Kilmacow, Co. Kilkenny", Nationality = "American"
                },
                new User {
                    Name = "Joe Bloggs", Address = "Carrick on Suir, Co. Tipperary", Nationality = "British"
                },
                new User {
                    Name = "Ann Other", Address = "Ferrybank, Co. Waterford", Nationality = "Irish"
                }
            };

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

            var permissions = new Permission[]
            {
                new Permission {
                    Title = "ReadOnly", Description = "Restricted to Read Only access"
                },
                new Permission {
                    Title = "Write", Description = "Allows Read and Write access"
                },
                new Permission {
                    Title = "Delete", Description = "Allows user to Delete files"
                }
            };

            foreach (Permission p in permissions)
            {
                context.Permissions.Add(p);
            }
            context.SaveChanges();

            var userpermissions = new UserPermission[]
            {
                new UserPermission {
                    UserID       = users.Single(u => u.Name == "Jim Fig").ID,
                    PermissionID = permissions.Single(p => p.Title == "Write").PermissionID
                },
                new UserPermission {
                    UserID       = users.Single(u => u.Name == "Jim Fig").ID,
                    PermissionID = permissions.Single(p => p.Title == "Delete").PermissionID
                },
                new UserPermission {
                    UserID       = users.Single(u => u.Name == "Jane Doe").ID,
                    PermissionID = permissions.Single(p => p.Title == "ReadOnly").PermissionID
                },
                new UserPermission {
                    UserID       = users.Single(u => u.Name == "Joe Bloggs").ID,
                    PermissionID = permissions.Single(p => p.Title == "Write").PermissionID
                },
                new UserPermission {
                    UserID       = users.Single(u => u.Name == "Ann Other").ID,
                    PermissionID = permissions.Single(p => p.Title == "Write").PermissionID
                }
            };

            foreach (UserPermission u in userpermissions)
            {
                context.UserPermissions.Add(u);
            }
            context.SaveChanges();
        }
Exemple #3
0
 public DeleteModel(StoreApp.Data.StoreAppContext context)
 {
     _context = context;
 }
Exemple #4
0
 public DetailsModel(StoreApp.Data.StoreAppContext context)
 {
     _context = context;
 }
Exemple #5
0
 public CreateModel(StoreApp.Data.StoreAppContext context)
 {
     _context = context;
 }
Exemple #6
0
 public IndexModel(StoreApp.Data.StoreAppContext context)
 {
     _context = context;
 }
 public Repository(StoreAppContext context)
 {
     _context = context;
 }