public VillainsController(VillainsContext context) { _context = context; if (_context.Villains.Count() == 0) { _context.Villains.Add(new Villain() { Name = "Junq", Powers = "Can make weapons and gadgets out of anything available", Hobbies = "Crochet, macrame, kidnapping" }); _context.Villains.Add(new Villain() { Name = "Darkness", Powers = "Converts light into darkness", Hobbies = "Robbing banks, blackmail, puzzles" }); _context.Villains.Add(new Villain() { Name = "Blast Wave", Powers = "Generates concussive blasts with his hands", Hobbies = "General villainy, doggie dancing" }); _context.Villains.Add(new Villain() { Name = "Smoke Jumper", Powers = "Can control fire and smoke", Hobbies = "Extortion, arson, poetry" }); _context.SaveChanges(); } }
public IActionResult AddVillain([FromBody] Villain item) { _context.Villains.Add(item); _context.SaveChanges(); return(Ok(new { success = true, returncode = "200" })); }