public int Update([FromBody] Unit unit) { if (!ModelState.IsValid) { return(-1); } _context.Update(unit); _context.SaveChanges(); return(0); }
//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); }