public IActionResult Create([FromBody] GoalsItem item) { if (item == null) { return(BadRequest()); } _context.GoalsItems.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetProgress", new { id = item.Id }, item)); }
public GoalsController(GoalsContext context) { _context = context; if (_context.GoalsItems.Count() == 0) { _context.GoalsItems.Add( new GoalsItem { MeasureId = "value", Value = 7.8, DisplayValue = "7.8", DisplayText = "number", } ); _context.SaveChanges(); } }