Esempio n. 1
0
        public Unit Add([FromBody] Unit unit)
        {
            if (!ModelState.IsValid)
            {
                return(null);
            }

            _context.Add(unit);
            _context.SaveChanges();
            return(unit);
        }
Esempio n. 2
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);
        }