public IActionResult Create([FromBody] AlertItem item) { if (item == null) { return(BadRequest()); } _context.AlertItems.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetAlert", new { id = item.Id }, item)); }
public AlertController(AlertContext context) { _context = context; if (_context.AlertItems.Count() == 0) { _context.AlertItems.Add(new AlertItem { Name = "Item1" }); _context.SaveChanges(); } }