public async Task <IActionResult> Edit(int id, [Bind("BloggID,Title")] Blogg blogg) { if (id != blogg.BloggID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(blogg); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BloggExists(blogg.BloggID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(blogg)); }
public async Task <IActionResult> Create([Bind("BloggID,Title")] Blogg blogg) { if (ModelState.IsValid) { _context.Add(blogg); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(blogg)); }
public int createBlogg(String BloggName) { Blogg blogg = new Blogg { BloggName = BloggName }; _db.Bloggs.Add(blogg); _db.SaveChanges(); int id = blogg.BloggId; return(id); }
public static void Seed(ApplicationDbContext context) { var bloggOne = new Blogg { Title = "A blogg about programming" }; context.Bloggs.Add(bloggOne); var coolPost = new Post { Blogg = bloggOne, Title = "Small CAPS@blah!" }; context.Posts.Add(coolPost); var bloggTwo = new Blogg { Title = "C#" }; context.Bloggs.Add(bloggTwo); var CSharp = new Post { Blogg = bloggTwo, Title = "Codes and stuff" }; context.Posts.Add(CSharp); var bloggThree = new Blogg { Title = "Java Script" }; context.Bloggs.Add(bloggThree); var JavaScript = new Post { Blogg = bloggThree, Title = "Web stuff is cool!" }; context.Posts.Add(JavaScript); context.SaveChanges(); }