public Unit Add([FromBody] Unit unit) { if (!ModelState.IsValid) { return(null); } _context.Add(unit); _context.SaveChanges(); return(unit); }
//we need `FromBody` since this is a complex type public Student Add([FromBody] Student student) { if (!ModelState.IsValid) { return(null); } _context.Add(student); _context.SaveChanges(); return(student); }