Exemplo n.º 1
0
        public async Task <IActionResult> PutEnrollmentByAge([FromRoute] int id, [FromBody] EnrollmentByAge enrollmentByAge)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != enrollmentByAge.EnrollmentByAgeId)
            {
                return(BadRequest());
            }

            _context.Entry(enrollmentByAge).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EnrollmentByAgeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(enrollmentByAge));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PostEnrollmentByAge([FromBody] EnrollmentByAge enrollmentByAge)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.EnrollmentByAges.Add(enrollmentByAge);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEnrollmentByAge", new { id = enrollmentByAge.EnrollmentByAgeId }, enrollmentByAge));
        }