public async Task <IActionResult> Edit(string id, [Bind("AwsInstanceID,Region,InstanceState")] AwsInstance awsInstance) { if (id != awsInstance.AwsInstanceID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(awsInstance); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AwsInstanceExists(awsInstance.AwsInstanceID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(awsInstance)); }
public static void Initialize(AwsContext context) { context.Database.EnsureCreated(); // Look for any data. if (context.AwsInstances.Any()) { return; // DB has been seeded } // Set initial data to AwsInstance var awsinstances = new AwsInstance[] { new AwsInstance { AwsInstanceID = "000000", Region = "nowhere", InstanceState = "unknown", Environment = "Uknown", Name = "Unknown" }, //new AwsInstance{ AwsInstanceID = "111111", Region = "nowhere", InstanceState = "unknown" } }; // Add initial data to Database foreach (AwsInstance aws in awsinstances) { context.AwsInstances.Add(aws); } context.SaveChanges(); }
public async Task <IActionResult> Create([Bind("AwsInstanceID,Region,InstanceState")] AwsInstance awsInstance) { if (ModelState.IsValid) { _context.Add(awsInstance); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(awsInstance)); }
public AwsInstanceViewModel(AwsInstance awsInstance) { awsInstance = awsInstance ?? throw new ArgumentNullException(nameof(awsInstance)); Id = awsInstance.Id; IpAddress = awsInstance.IpAddress; ReportLines = awsInstance.ReportLines.Where(x => x.Parent == null) .Select(x => new ReportLineViewModel(x)) .Where(x => !x.IsEmptyRoot) .OrderBy(x => x.Name) .ToArray(); }