Esempio n. 1
0
        public async Task SeedData()
        {
            if (!_context.Users.Any())
            {
                var user = new qualitysystemUser()
                {
                    UserName = "******",
                    Email    = "*****@*****.**"
                };

                await _userManager.CreateAsync(user, "[email protected]");

                await _context.SaveChangesAsync();
            }
            if (!_context.Devices.Any())
            {
                var firstDevice = new Device()
                {
                    SerialNumber = "XCF0056",
                    Type         = DeviceType.PC,
                    Spare        = false,
                    Broken       = false,
                    Components   = new List <Component>()
                    {
                        new Component()
                        {
                            Type = type.MotherBoared, Description = "G41"
                        },
                        new Component()
                        {
                            Type = type.HardDiskDrive, Description = "250GB"
                        },
                        new Component()
                        {
                            Type = type.RAM, Description = "4GB"
                        },
                    },
                    Location = new Location()
                    {
                        Name = "Lab 1"
                    },
                    Model = new Model()
                    {
                        Name        = "HP",
                        DateEntered = DateTime.UtcNow,
                        PageNumber  = "144/1"
                    }
                };

                _context.Locations.Add(firstDevice.Location);
                _context.Models.Add(firstDevice.Model);
                _context.Devices.Add(firstDevice);
                _context.Components.AddRange(firstDevice.Components);
                await _context.SaveChangesAsync();
            }
        }
Esempio n. 2
0
 public async Task <bool> SaveChangesAsync()
 {
     return(await(_context.SaveChangesAsync()) > 0);
 }