public async Task <IActionResult> Edit(int id, [Bind("BedaprogramID,Name")] Bedaprogram bedaprogram) { if (id != bedaprogram.BedaprogramID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bedaprogram); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BedaprogramExists(bedaprogram.BedaprogramID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bedaprogram)); }
public async Task <IActionResult> Create([Bind("BedaprogramID,Name")] Bedaprogram bedaprogram) { if (ModelState.IsValid) { _context.Add(bedaprogram); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bedaprogram)); }
public static void Initialize(ApplicationDbContext context) { context.Database.EnsureCreated(); // Look for any students. if (context.Location.Any()) { return; // DB has been seeded } var locations = new Location[] { new Location { Name = "Drawer One Cabnet One" } }; foreach (Location s in locations) { context.Location.Add(s); } context.SaveChanges(); var goal = new Goal[] { new Goal { Name = "My Goal" } }; foreach (Goal s in goal) { context.Goal.Add(s); } context.SaveChanges(); var beda = new Bedaprogram[] { new Bedaprogram { Name = "Example Program" } }; foreach (Bedaprogram s in beda) { context.Bedaprogram.Add(s); } context.SaveChanges(); var advisors = new Advisor[] { new Advisor { FirstName = "Sample", LastName = "Advisor" } }; foreach (Advisor s in advisors) { context.Advisor.Add(s); } context.SaveChanges(); }